DEV Community

Cover image for Learning JavaScript Simplified!
JaneOma
JaneOma

Posted on

Learning JavaScript Simplified!

JavaScript is a frontend programming language, which makes the web page interactive with HTML and CSS. In JavaScript, only one thing ever happens at a time. This means it is single-threaded.
It is streamlined into different variables, which include;

  • Objects
  • Arrays
  • Functions
  • Strings
  • Numbers

Objects

This is a collection of data, it is a variable in JavaScript which helps the developer to group like-information together, each key has to be unique per object but values do not have to be unique. It contains curly brackets. They contain named values called properties or methods.
Example:

Objects properties                 Property value
firstName                           Mike
lastName                            John
age                                 45
hairColour                          brown
Enter fullscreen mode Exit fullscreen mode

Method
This is a function stored as a property. They are actions that can be performed on objects.
Example:

var person = {
firstName:    "Mike",
lastName:     "John",
id      :      5566,
fullName:     function() {
 return this.firstName + "" + this.lastName;
} 
};

Enter fullscreen mode Exit fullscreen mode

Arrays

They are single objects that contain multiple values, it is also an ordered collection of data. Array Objects reduces the time and stress of calling the code for every item in a separate variable.
The first element of an array is index zero.
Creating Arrays
Arrays contain single square brackets and elements that are separated by commas. In arrays, we can store various data types: strings, numbers, objects, and also other arrrays.

Array Methods
The Sort()Method sorts the elements of an array in-place and returns the sorted array. The time and space complexity of the sort cannot be guaranteed as it depends on how it is implemented.
Example:

const months = ['March', 'Jan', 'Feb', 'Dec'];
months.sort();
console.log(months);
// expected output: Array ["Dec", "Feb", "Jan", "March"]
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
fuchodeveloper profile image
Fredrick Mgbeoma

Really good read!
Keep it up