JavaScript was introduced in 1995 to add programs to web pages in the Netscape Navigator browser. The language has since been adopted by all other major graphical web browsers. It has made modern web applications possible, with which you can interact directly without doing a page reload for every action. JavaScript is also used in more traditional websites to provide various forms of interactivity and cleverness.
Javascript is a cross-platform, object-oriented scripting language used to make webpages interactive (e.g., habing complex animations, clickable buttons etc). There are also more advanced server-side versions of javascript such as Node js, which allows you to add more functionality to a website than downloading files.
JavaScript is one of the most popular languages which includes numerous features when it comes to web development. It’s amongst the top programming languages as per Github and we must know the features of JavaScript properly to understand what it is capable of.
1.Light Weight Scripting language
2.Dynamic Typing
3.Object-oriented programming support
4.Functional Style
5.Platform Independent
6.Prototype-based
Let’s see all these features in detail so you can understand them starting from the first to the last
1. Light Weight Scripting Language
JavaScript is a lightweight scripting language because it is made for data handling in the browser only. Since it is not a general-purpose language it has a limited set of libraries. Also as it is only meant for client-side execution and that too for web applications, hence the lightweight nature of JavaScript is a great feature.
2. Dynamic Typing
JavaScript supports dynamic typing which means types of the variable are defined based on the stored value. For example, if you declare a variable x then you can store either a string or a Number type value or an array or an object. This is known as dynamic typing.
3. Object-Oriented Programming Support
Starting from ES6, the concept of class and OOPs has been more refined. Also, in JavaScript, two important principles with OOP in JavaScript are Object Creation patterns (Encapsulation) and Code Reuse patterns (Inheritance). Although JavaScript developers rarely use this feature but is there for everyone to explore.
3. Functional Style
This implies that JavaScript uses a functional approach, even objects are created from the constructor functions and each constructor function represents a unique object-type. Also, functions in JavaScript can be used as objects and can be passed to other functions too.
4. Platform Independent
This implies that JavaScript is platform-independent or we can say it is portable; which simply means that you can simply write the script once and run it anywhere and anytime. In general, you can write your JavaScript applications and run them on any platform or any browser without affecting the output of the Script.
5. Prototype-based Language
JavaScript is a prototype-based scripting Language. This means JavaScript uses prototypes instead of classes or inheritance. In languages like Java, we create a class and then we create objects for those classes. But in JavaScript, we define an object prototype and then more objects can be created using this object prototype.
7. Interpreted Language
JavaScript is an interpreted language which means the script written inside javascript is processed line by line. These Scripts are interpreted by JavaScript interpreter which is a built-in component of the Web browser. But these days many JavaScript engines in browsers like the V8 engine in Chrome use just-in-time compilation for JavaScript code.
8. Async Processing
JavaScript supports Promise which enables asynchronous requests wherein a request is initiated and JavaScript doesn’t have to wait for the response, which at times blocks the request processing. Also starting from ES8, Async functions are also supported in JavaScript, these functions don’t execute one by one, rather they are processed parallelly which has a positive effect on the processing time, reducing it to a great extent.
It is worth noting the core differences between Java and JavaScript.
Javascript and Java are similar in some ways but fundamentally different in some others.
JavaScript は Java と比較して自由形式の言語です。すべての変数、クラス、メソッドを宣言する必要はありません。メソッドがパブリック、プライベート、プロテクトのいずれであるかを気にする必要はなく、インターフェイスを実装する必要もありません。一方、Java は高速実行と型安全性を目的として設計されたクラスベースのプログラミング言語であり、キャストすることはできません。 Java 整数をオブジェクト参照に挿入するか、Java バイトコードを破損してプライベート メモリにアクセスします。
Es6(ECMAScript 2015) は、シンプルさと読みやすさに重点を置いた多くの新機能を含む JavaScript のメジャー アップデートです。7
これらの新機能と、それをいつどのように使用するかについて調べてみましょう
1. let と const キーワード
Es6 が導入される前は、JavaScript で変数を宣言するには var キーワードが唯一の方法でした。 const キーワードを使用すると、変数を定数として宣言でき、定数として宣言すると読み取り専用になります。
2.アロー関数
ここでは => を使用します。関数キーワードの代わりに。アロー関数を使用すると、コードがより読みやすく、わかりやすく、短くなります。
3.オブジェクト
オブジェクトは、キーと値のペアで構成される単なるプロパティのコレクションです。
4.クラス
class キーワードは、関数とプロトタイプを使用してクラスのような継承階層をシミュレートするパターンを形式化するために使用されます。
5.約束
これにより、非同期呼び出しが簡単かつ楽になります。
6.テンプレートリテラル
テンプレート リテラルとは、単に文字列内に変数があることを意味します。
読んでくれてありがとう、そしていつもあなたを応援していることを知っておいてください!!!!
The above is the detailed content of A basic Introduction to Javascript. For more information, please follow other related articles on the PHP Chinese website!