Preparing for JS Flashcards
What is JavaScript?
JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions. JavaScript is a prototype-based, multi-paradigm, single-threaded, dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles.
What is Just-in-time compilation?
In computing, just-in-time (JIT) compilation (also dynamic translation or run-time compilations)[1] is a way of executing computer code that involves compilation during execution of a program (at run time) rather than before execution.
What does it mean that a language has First-class Function?
A programming language is said to have First-class functions when functions in that language are treated like any other variable. For example, in such a language, a function can be passed as an argument to other functions, can be returned by another function and can be assigned as a value to a variable.
What is Prototype-based programming
Prototype-based programming is a style of object-oriented programming in which classes are not explicitly defined, but rather derived by adding properties and methods to an instance of another class or, less frequently, adding them to an empty object.
What is multi-paradigm
Some languages are designed to support one paradigm (Smalltalk supports object-oriented programming, Haskell supports functional programming), while other programming languages support multiple paradigms (such as Object Pascal, C++, Java, JavaScript, C#, Scala, Visual Basic, Common Lisp, Scheme, Perl, PHP, Python, Ruby
What is single-threaded programming lang?
Single threaded processes contain the execution of instructions in a single sequence. In other words, one command is processes at a time. The opposite of single threaded processes are multithreaded processes. These processes allow the execution of multiple parts of a program at the same time.
Why is js a dynamic language?
Most languages have some aspect of dynamic behaviour. Even statically typed languages can have a dynamic or variant data type that can contain different data types.
JavaScript is called a dynamic language because it doesn’t just have a few dynamic aspects, pretty much everything is dynamic.
All variables are dynamic (both in type and existance), and even the code is dynamic. You can create new variables at runtime, and the type of variables is determined at runtime. You can create new functions at any time, or replace existing functions. When used in a browser, code is added when more script files are loaded, and you can load more files any time you like.
Nowadays JavaScript is compiled in many implementations, and static code and static types are generated in the background. However, the behaviour is still dynamic, the compiler only generates static types when it finds that the dynamic aspects are not used for a specific object.
Why is js lightweight?
There Aren’t Too Many Language Structs Available
It’s Not Strongly Typed
Simple Language Build Blocks
Simple Syntax, Easy to Learn
Common and Best Practices Are Easier to Pick Up
High Level Language
What does it mean?
There Aren’t Too Many Language Structs Available
JavaScript does not have too many language constructs that you can use for building your code. We have functions, different types of loops that can be used on different types of data structures, and built in objects like Math, Date, Array and so. Also statements (like if-else), and declarations (like const, let) are available for creating variables. On first glimpse this does not sound monumental, but these constructs can be used almost too freely, whichever use case we need to cover.
What does it mean? JS is Not Strongly Typed
JavaScript uses dynamic typing, so everything that you declare or assign, the interpreter tries to figure out, what should be the type of a certain variable. After figuring out what is the type of a variable, it assigns type specific methods to the variable inheriting from its Object Prototype Chain.
Advantages can be that we have incredible freedom in how we want to write our code. Some of this freedom makes really clever workarounds possible, offers solutions to common problems and what preferred solution we choose.
What does it mean? Js has Simple Language Build Blocks
In JavaScript everything is treated as an object, you can just declare a variable and access a lot of predefined methods right away. Or you can just create a function that processes and handles some data. Much less abstractions than other programming languages like Java or C#.
Devs can choose between an Object Oriented approach, or a functional declarative way to write code in this language.
What does it mean? Js has Simple Syntax, Easy to Learn
Since JavaScript takes care of a lot of things under the hood, such as dynamic typing, starting programmers can focus on understanding the key concepts, and looking for best practices even in the beginning. With JavaScript, developers can focus on data structures, and best practices more, since the language is simpler in nature.
What does it mean? Js Common and Best Practices Are Easier to Pick Up
In the last decade JavaScript developed a lot, and developers figured out a lot of best practices that can be used writing an application. Performance and ‘Clean Code’ best practices and design patterns are applied more and more. Even these are heavily included in the design and architecture of modern JavaScript frameworks such as Angular, React, Vue.
What does it mean? Js is a High Level Language
JavaScript is less hardware close, it means that its core functions are handled in a lower level machine / engine (like memory allocation, pointers, garbage collection, or threading). Also its concurrency model the infamous “Event Loop” is also handled automatically.
For most of the use cases developers regularly meet, they don’t really need to know what happens under the hood, unless they need to do hardcore performance optimization, or using async solutions.
What does it mean? Js is interpreted
JavaScript is an interpreted language, not a compiled language. A program such as C++ or Java needs to be compiled before it is run. … In contrast, JavaScript has no compilation step. Instead, an interpreter in the browser reads over the JavaScript code, interprets each line, and runs it.