CHAPTER 4

image

Writing Scripts in Nashorn

In this chapter, you will learn:

  • How to write scripts in Nashorn
  • The difference between running the script in strict mode and nonstrict mode
  • How to declare variables and write comments
  • Primitive and object data types, and how to convert values of one data type to another data type
  • Operators, statements, and creating and invoking functions in Nashorn
  • Different ways of creating and using objects
  • Variable scoping and hoisting
  • About built-in global objects and functions

Nashorn is a runtime implementation of the ECMAScript 5.1 specification on the JVM. ECMAScript defines its own syntax and constructs for declaring ...

Get Scripting in Java: Integrating with Groovy and JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.