Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Javascript Package keyword used for?

I was reading some online material on reserved JavaScript keywords and I came across the word package.

I couldn't find any clear online material that could explain what it is useful for.

like image 200
Dasaru Avatar asked May 29 '11 11:05

Dasaru


People also ask

What does the package keyword do?

The package keyword is used to specify a directory structure to which the current source file must belong. For example, package com. mycompany.

Is package a keyword in JavaScript?

package is a keyword (from Java) reserved for possible later use in JavaScript.

What is JavaScript package?

What is a Package? A package in Node. js contains all the files you need for a module. Modules are JavaScript libraries you can include in your project.

What is the use of keywords in JavaScript?

The with keyword is used as a kind of shorthand for referencing an object's properties or methods. The object specified as an argument to with becomes the default object for the duration of the block that follows. The properties and methods for the object can be used without naming the object.


2 Answers

It is reserved, but not necessarily used (well, not at least of time of writing).

The following are reserved as future keywords by the ECMAScript specification. They have no special functionality at present, but they might at some future time, so they cannot be used as identifiers. (Note that for the moment Mozilla reserves these keywords only in strict mode code. Most other browsers reserve these keywords in all code, whether strict or not, so their use is very much non-portable. Mozilla will likely reserve these keywords in normal code in a future release, to conform to the specification and to be consistent with other browsers).

Source.

like image 97
alex Avatar answered Oct 18 '22 14:10

alex


The following are reserved as future keywords by the ECMAScript specification when they are found in strict mode code, except that let and yield have their traditional Mozilla-specific functionality in code compiled as JavaScript 1.7 or greater:

  • implements
  • interface
  • let
  • package
  • private
  • protected
  • public
  • static
  • yield

More information from MDC: https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words

like image 22
MacMac Avatar answered Oct 18 '22 15:10

MacMac