4.1.1. More On Strings¶ code example

Example 1: 4.1.1. More On Strings¶

console.log(42, 17, 56, 34, 11, 4.35, 32);
console.log(3.4, "hello", 45);

//42 17 56 34 11 4.35 32
//3.4 hello 45

Example 2: 4.1.1. More On Strings¶

console.log(42000);
console.log(42,000);

//42000
//42 0

Example 3: 4.1.1. More On Strings¶

console.log('Bruce's beard');

/*Strings in JavaScript can be enclosed in either single quotes (') 
or double quotes (").Double-quoted strings can contain single quotes 
inside them, as in "Bruce's beard", and single quoted strings can have
double quotes inside them, as in 'The knights who say "Ni!"'.
JavaScript doesn't care whether you use single or double quotes to 
surround your strings. Once it has parsed the text of your program or 
command, the way it stores the value is identical in all cases, and the
surrounding quotes are not part of the value./*

Warning
If a string contains a single quote (such as "Bruce's beard") 
then surrounding it with single quotes gives unexpected results./*

console.log('Bruce's beard');*/

Example 4: 4.1.1. More On Strings¶

console.log(typeof 'This is a string');
console.log(typeof "And so is this");

//string
//string

Example 5: 4.1.1. More On Strings¶

console.log(typeof "17");
console.log(typeof "3.2");

/*What about values like "17" and "3.2"? They look like numbers, 
but they are in quotation marks like strings.
Run the following code to find out./*