What is JAVASCRIPT?

JAVASCRIPT

JavaScript is a HIGH-LEVEL PROTOTYPE-BASED OBJECT-ORIENTED MULTI-PARADIGM INTERPRETED OR JUST-IN-TIME COMPILED DYNAMIC SINGLE-THREADED GARBAGE-COLLECTED programming language with FIRST-CLASS FUNCTIONS.

(1) High-level

Any computer program needs resources  for example CPU. JavaScript do not have to manage resources at all, because these languages hava so-called abstractions. This makes language easier to learn and to use, but the downside is that programs will never be as fast or as optimized as for example, C programs.

(2)Garbage-collected

An algorithm inside the JavaScript engine which automatically removes old, unused objects from the computer memory, in order not to clog it up with unnecessary stuff so it's a little bit JavaScript has a cleaning guy who cleans our memory from time to time so that we don't hava to do ti manually in our code.

(3)Interpreted or just-in-time complied

Computer's processor only understands zeros and ones. Ultimately, every single program needs to be written in zeros and ones, which is also called machine code. We simply write human-readable JavaScript code, which is an abstraction over machine code but this code eventually needs to be translated to machine code and that step can be either compiling or interpreting.

In JavaScript, this happens inside the JavaScript engine.

(4)multi-paradigm

In programming, a paradigm is an approach and an overall mindset of structuring our code, which will ultimately direct the coding style and technique in a project that uses a certain paradigm.

THERE ARE THREE PARA:  (1) Procedural programming

                                               (2)Object-oriented programming(OOP)

                                               (3)Functional programming(FP)

We also can classify PARA as imperative and declarative.

(5)Prototype-based object-oriented

Almost everything in JavaScript is an object except for primitive values such as numbers strings, but arrays are just object, why we can creat an array and then use the push method on ti? for example

const arr = [1, 2, 3];
arr.push(4);
const hasZero = arr.indexOf(0) > -1

it's because of prototypal inheritance.We create arrays from an array blueprint which is like a template and this is called the prototype it contains all the array methods and the arrays that we create in our code then inherit the methods from the blueprint so that we can use them on the arrays.

(6)First-class functions

Functions are siimple treated as variables.

We can pass functions into other functions and we can return functions from functions, this is extremly powerful, because it allows us to use a lot of powerful techniques and also allows for functional-prgramming.

EXAMPLE

const closeModal = () =>{
  modal.classList.add('hidden');
  overlay.classList.add('hidden');
};

overlay.addEventListener('click',closeModal);

We pass the closeModal into the addEventListener function as if it was just a regular variable.

(7)Dynamic

Dynamic-typed language

let x = 1;
let y = 10;
x = 'TT';

We don't assign data types to variables, they only can be know when JavaScript engine executes our code, and the type of variavles can easily be changed as we reassign variables.

(8)Single-threaded and Non-blocking exent loop

Concurrency model: how the JavaScript engine multiple tasks happening at the same time.

JavaScript runs in one single thread, so it can only do one thing at a time.Therefore we need a way of handing multiple things happening at the same time.

When we hava a long-running task: It would block the single thread. HOWEVER, we want non-blocking behavior.

By using an event loop: tasks long running tasks, executes them in the "background", and puts them in the main thread once they are finished.

  • 25
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值