DEV Community

Darlene Rivera
Darlene Rivera

Posted on

We all know JavaScript

I think we all know JavaScript, yes; if you know about Objects, Functions, Arrays, Boolean, Numbers, then you know JavaScript!

We know that an object allow us to store related pieces of information in a single central location

let object = {
  /*
  this is a single central location
  */
}
Enter fullscreen mode Exit fullscreen mode

and to store an object we declare a variable and set it equal to an opening and closing parenthesis.

//object is the variable that stores our Object
let object = {
  // these are related pieces of information
  name: 'Agbeze Obinna',
  age: 25,
  location: 'Nigeria'
}
Enter fullscreen mode Exit fullscreen mode

We also know about object name, properties and property values. And we access those property values like so..

// the object name followed by a dot, followed by the property
// whose value you are trying to get
object.name
object.age
Enter fullscreen mode Exit fullscreen mode

We also know that a function is a sub program that allows us to do some interesting things multiple times or let’s say listen for a button click. Every single thing that happens on the screen (user-interface) is the work of a function, when you view a web page, behind the scene multiple functions has executed. We can also store a function in a variable like so…

let myFunction = function () {
  // this is a function body
}
Enter fullscreen mode Exit fullscreen mode

And for our function to execute we call it like so..

// calling a function
myFunction()
Enter fullscreen mode Exit fullscreen mode

We also know Arrays allow us to store a list of information, we might have a list of string, a list of numbers, a list of objects and a list of whatever we like..

let myArray = [/* everthing here is called an Array */]
Enter fullscreen mode Exit fullscreen mode
// Storing a string in Array
let stringArray = ['Pray', 'for the', 'World against', 'Corona Virus']

// storing numbers
let numberArray = [1, 2, 3, 4, 5]
Enter fullscreen mode Exit fullscreen mode

We can also store an object inside of Array and when we do that, we call it Array of Objects...

// storing object in an Array
let objectInArray = [{name: 'Collins', age: 25}, {name: 'Nora', age: 19}, {name: 'Andrew', age: 29}]
Enter fullscreen mode Exit fullscreen mode

We also know it can be true or false, when we use the if statement or Array method to manipulate Arrays/Arrays of Object and we expect true or false which is called a Boolean, only then do we have access to the individual objects or Arrays.

// Arrays to manipulate
let objectToManipulate = [{name: 'Agbeze', age: 25}, {name: 'Nora', age: 19}, {name: 'Andrew', age: 29}]


// manipulating Arrays with find method
const manipulateArrays = (functionParameter) => {
const result = objectToManipulate.find((insideArray) => {

  return insideArray.age === functionParameter
})
  console.log(result.age === 25) // we are printing TRUE to the screen
}
// calling our function
manipulateArrays(25)
Enter fullscreen mode Exit fullscreen mode

We also know about numbers in JavaScript, where we perform math related operations. When working with Numbers in JavaScript , it can also include some Math related methods like so..

// a random number is coming back
 let num = Math.floor(Math.random() * (10 - 20)) + 10
Enter fullscreen mode Exit fullscreen mode

If you actually know how to do all these stuffs, then I believe you know JAVASCRIPT.
BRAVO!!!

Top comments (0)