Hi friends we know what is javascript.And next important thing is what are the reserved keywords of javascript.The reserved keywords are specified by ECMA .
Note: In this year(2015) ,ECMA 6th script will be announced officially.
default
function
return
var
case
delete
if
switch
void
catch
do
in
this
while
const
else
instanceof
throw
with
continue
finally
let
try
debugger
for
new
typeof
The following are future reserved words:
class
enum
export
extends
import
super
interface
package
private
protected
public
static
yield
Open notepad copy and paste the below code and save as index.html.Then open with web browser you will get output 11 .I used x and y as variables here.
Now again open notepad copy and paste the below code and save as index2.html.Then open with web browser you will not get output anything .I used continue and break as variables which are javascript reserved keywords.
Who was ECMA?
Actually ECMA is a scripting language which works on the client web side .Javascript was developed by Brendan Eich of Netscape under the name of Mocha.Then name mocha was renamed to LiveScript. Finally livescript was renamed to JavaScript. Actually ECMA is the core of the javascript but not only contains all things of ECMA but also it has some other things which was not in ECMA. For standardization purpose javascript moved to ECMA specification with the name of ECMA-262.Now the javascript keywords are announced officially upto ECMA 5th script specifications.Note: In this year(2015) ,ECMA 6th script will be announced officially.
Why it is essential to know about javascript reserved keywords?
Because we cannot use the reserved keywords as identifiers or variables or function names.The identifiers are nothing a combination of alphanumeric characters. Actually javascript reserved words are identifiers but we should not use it for function names and variables.Javascript reserved words are part of the language syntax. If we use a reserved word as variables then it causes a compilation error when loading your script.List of javascript reserved words
breakdefault
function
return
var
case
delete
if
switch
void
catch
do
in
this
while
const
else
instanceof
throw
with
continue
finally
let
try
debugger
for
new
typeof
List of future javascript reserve words
The following are future reserved words:
class
enum
export
extends
import
super
List of future javascript reserve words in strict mode
implementsinterface
package
private
protected
public
static
yield
An Example to explain why we should not use javascript reserved words as variables
Open notepad copy and paste the below code and save as index.html.Then open with web browser you will get output 11 .I used x and y as variables here.
<p id="abc"></p>
<script>
var x = 5;
var y = 6;
document.getElementById("abc").innerHTML =
x+y;
</script>
Now again open notepad copy and paste the below code and save as index2.html.Then open with web browser you will not get output anything .I used continue and break as variables which are javascript reserved keywords.
<p id="abc"></p>A sample animated gif tutorial was given below to explain why we should not use javascript reserved words.
<script>
var continue = 5;
var break = 6;
document.getElementById("abc").innerHTML =
continue+break;
</script>
0 comments :
Post a Comment