Javascript Array, String, Number discussion
String: String object used to represent and manipulate a sequence of character
Character Access: we can access character with the charAt() method Example: return ‘Raj’ .charAt(1)
Comparing String: We can comparing strings by use less-than & greater-than operators.
Example:let a = 'a'
let b = 'b'
if (a < b) { // true
console.log(a + ' is less than ' + b)
} else if (a > b) {
console.log(a + ' is greater than ' + b)
} else {
console.log(a + ' and ' + b + ' are equal.')
}
Number: JavaScript has only one type of number. Numbers can be written with or without decimals.
Number is NaN: When we pass the value not a number.
Number is Integer: when we pass a integer value
Numbers . Farsefloat: when we can change the number formet to float Formet.
Array: JavaScript arrays are used to store multiple values in a single variable.Example: var array_name = [item1, item2, …];
Add an item to the end of an array: we can add item end of array with push()method. Example: let newLength = fruits.push('Orange')
Remove an item from the end of an Array: we can remove item end of array with pop() method. Example: let last = fruits.pop()
Remove an item from the beginning of an Array: we can remove item start of array with shift() method. Example: let first = fruits.shift()