Declarative Programming:
In declarative programming, code focuses on what the program should achieve, describing the result rather than the step-by-step process. It often involves higher-level abstractions and allows for a more concise and readable code.
Changing Method:
It seems like there might be a bit of confusion in your question. If you are asking about changing elements in an array in JavaScript, you might be referring to methods like map or forEach which can be used to transform or modify array elements.
map Method:
The map method creates a new array by applying a function to each element of an existing array.
forEach Method:
The forEach method executes a provided function once for each array element.
Object-oriented programming (OOP):
Object-oriented programming (OOP) is a programming paradigm that uses objects to organize and structure code. JavaScript is a multi-paradigm language that supports object-oriented programming. Here are the key concepts of OOP in JavaScript:
Objects and Classes:
JavaScript allows you to create objects either through object literals or constructor functions. With the introduction of ES6, classes were introduced as a syntactical sugar over constructor functions for creating objects.
Encapsulation:
Encapsulation involves bundling the data (properties) and the methods (functions) that operate on the data into a single unit, i.e., an object. This helps in hiding the internal details of the object and exposing only what is necessary.
Inheritance:
Inheritance is a mechanism that allows a class (or constructor function) to inherit properties and methods from another class. In JavaScript, this is achieved through the prototype chain.
JavaScript allows you to create objects either through object literals or constructor functions. With the introduction of ES6, classes were introduced as a syntactical sugar over constructor functions for creating objects.
Polymorphism:
Polymorphism allows objects to be treated as instances of their parent class. This allows for flexibility in the structure and behavior of the program.