JavaScript is a multi-paradigm, object-oriented and dynamic language. Its syntax based on the Java and c languages. JavaScript programs manipulate values, and those values all belong to a type. JavaScript’s types are:

  1. String
  2. Boolean
  3. Function
  4. Object
  5. Symbol

Number

Number is a primitive wrapper object used to represent.

The number constructor contains constants and methods for working with numbers. Values of other types can be converted to numbers using the number () function.

parseInt(): ParseInt is a built-in function. It’s convert a string to an integer.

parseInt('111'); // 111
parseInt('090'); // 90

NaN: NaN is short of “not a number”. It’s returned if the string is non-numeric.

parseInt('Fatiha', 10); // NaN

String

The string object is used to represent and manipulate a sequence of characters. String can be created as primitives, from string literals, or as objects, using the String() constructor.

const string primitive = "Fatiha";
const string primitive = 'Fatiha';
const string primitive = `Fatiha`;
const string primitive = new String("Fatiha");

There are two ways to access an individual character in a string. The first is the charAt() method and the second is an array like object;

return 'fatiha'.charAt(3) // returns "i"
return 'fatiha'[2] // returns "t"

Split: The split() method divides a string into an ordered list of substrings, puts these substrings into an array, and returns the array. The division is done by searching for a pattern; where the pattern is provided as the first parameter in the method's call.

const str = ‘The quick brown fox jumps over the lazy dog.’;

const str = ‘no pain no gain.’;
const words = str.split(‘ ‘);
console.log(words[3]);
// expected output: 'gain'

Array

The JavaScript array is a global object that is used in the construction of arrays; which are high-level, list-like objects. JavaScript arrays are zero-indexed. The first element of an array is at index 0, and the last element is at the index value equal to the value of the array's length property minus 1.

map(): The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.

const array1 = [1, 4, 9, 16];// pass a function to map
const map1 = array1.map(x => x * 2);
console.log(map1);
// expected output: Array [2, 8, 18, 32]

concat(): The concat() method is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array.

const array1 = ['a', 'b', 'c'];
const array2 = ['d', 'e', 'f'];
const array3 = array1.concat(array2);
console.log(array3);
// expected output: Array ["a", "b", "c", "d", "e", "f"]

pop(): The pop()method removes the last element from an array and returns that element. This method changes the length of the array.

const plants = ['Rahim', 'karim', 'jadu', 'mudhu', 'kuddus'];console.log(plants.pop());
// expected output: "kuddus"
console.log(plants);
// expected output: Array['Rahim', 'karim', 'jadu', 'mudhu'];

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

WebGoat CSRF 3 4

Thoughts on Application State

Clone Graph

Types of Forms

JSX — Up Close

Setting up React16, Babel 7, Webpack 4 Dev Server with Jest and Enzyme — Minimal Setup

How we integrate Google Maps or Mapbox Maps in your web, native mobile app or project.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Fatiha Zannat

Fatiha Zannat

More from Medium

How does react works? Today I’m sharing with you react’s processing.

Steering Clear of Mutations: Array Edition(ft. The Simpsons)

Do we really need flatMap ?

.flatMap, think twice, before using …

Job Search Update — JavaScript Arrays