HTML and CSS Reference
In-Depth Information
//
When using the console, variables will not be declared with the var keyword. As
you will see below, it is critical that this is used in most situations when writing
actual JavaScript code.
We can then inspect the type of this variable using the typeof operator:
> typeof s
"string”
Although strings are their own data type, it is possible to invoke methods on them just as
we will see it is possible to invoke methods on objects below.
> s.charAt(1)
"e"
> s.substr(6)
"world"
> s.toUpperCase()
"HELLO WORLD"
In addition, strings have properties that can be accessed, just as we will see on objects in
the examples below:
> s.length
11
JavaScript strings are largely equivalent to strings in Java. One consequence of this is that
strings are immutable.
 
Search WWH ::




Custom Search