javascript
- Чтобы org-babel работал с блоками кода, надо ставить nodejs. Вывод результатов через console.log. Тип блока: js.
- Комментарии -
/* многострочный комментарий */
и// комментарий до конца строки
. - https://stepik.org/cert/1198163 - это сертификатег со степика про javascript. Теперь есть картинка, что я с ним знакома :)
- gemini://gemlog.stargrave.org/9ecf9331987a62db1d012bef94c39406a1d6af60 - почему джаваскрипт, по крайней мере, как он используется в нынешних интернетах, зло (для тех, кто читает gemini).
- https://www.typescriptlang.org/docs/handbook/intro.html - TypeScript, язык-надстройка над джаваскриптом.
- https://habr.com/ru/companies/kryptonite/articles/741852/ - некоторая вводная статья
- json
Ссылки
- http://learn.javascript.ru
- https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference
- https://habr.com/ru/post/312880/ - математика в js
- https://habr.com/company/enterra/blog/153365/
- http://js-grid.com/ - дополнение к jQuery для таблиц-гридов.
- http://bonsaiden.github.io/JavaScript-Garden/ru/#core.eval
- Центральный Javascript-ресурс. Учебник с примерами скриптов. Форум. Книги и многое другое. http://javascript.ru/
- https://es5.javascript.ru/ - es5 javascript на русском
- https://docs.npmjs.com/ – про ставить пакеты для nodejs, который жабийскрип общего назначения.
w3 туториал примеры
https://www.w3schools.com/js/exercise_js.asp?filename=exercise_js_string_methods1 https://www.w3schools.com/js/js_strings.asp
После забега про разводяшку, который оказался не нужен:
- https://www.w3schools.com/js/js_objects.asp
- https://www.w3schools.com/jsref/dom_obj_textarea.asp
- https://www.w3schools.com/html/html_form_elements.asp
- https://www.w3schools.com/html/html_forms.asp
<p id="demo">JavaScript can change the style of an HTML element.</p>
<button type="button" onclick="document.getElementById('demo').style.fontSize='35px'">Click Me!</button>
<p id="demo">JavaScript can change HTML content.</p>
<button type="button" onclick='document.getElementById("demo").innerHTML = "Hello JavaScript!"'>Click Me!</button>
JavaScript can "display" data in different ways:
- Writing into an HTML element, using innerHTML.
- Writing into the HTML output using document.write().
- Writing into an alert box, using window.alert().
- Writing into the browser console, using console.log().
Using document.write() after an HTML document is loaded, will delete all existing HTML:
Массив
JavaScript Arrays
JavaScript arrays are written with square brackets.
Array items are separated by commas.
The following code declares (creates) an array called cars, containing three items (car names): Example var cars = ["Saab", "Volvo", "BMW"];
Хеш (Объект)
JavaScript Objects
JavaScript objects are written with curly braces {}.
Object properties are written as name:value pairs, separated by commas. Example var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
typeof - способ узнать, что тут прячется
typeof something
In JavaScript null is "nothing". It is supposed to be something that doesn't exist.
Unfortunately, in JavaScript, the data type of null is an object.
You can consider it a bug in JavaScript that typeof null is an object. It should be null. You can empty an object by setting it to null: Example var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"}; person = null; // Now value is null, but type is still an object
You can also empty an object by setting it to undefined: Example var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"}; person = undefined; // Now both value and type is undefined
undefined and null are equal in value but different in type: typeof undefined / undefined typeof null / object
null =
undefined / false
null == undefined / true
A primitive data value is a single simple data value with no additional properties and methods.
The typeof operator can return one of these primitive types:
string number boolean undefined
The typeof operator can return one of two complex types:
function object
The typeof operator returns "object" for objects, arrays, and null.
The typeof operator does not return "object" for functions.
Разное
- tool to launch modern Javascript scripts
Bash is great, but when it comes to writing scripts, people usually choose a more convenient programming language. JavaScript is a perfect choice, but standard Node.js library requires additional hassle before using. The `zx` package provides useful wrappers around `child_process`, escapes arguments and gives sensible defaults. Домашняя страница: https://github.com/google/zx - про запас на всяк случай.
Случайное целое число в диапазоне, включая минимальное и максимальное.
- Math.ceil — округляет все в большую сторону,
- Math.floor — в меньшую,
- Math.round — меньше 0.5 — в меньшую, больше 0.5 — в большую.
function getRandomInRange(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } console.log(getRandomInRange(0, 9))
convert int to string in javascript.
Using toString()
toString(base) function converts a given a number to the string. It takes an optional parameter base which can be used to specify the base in which the number will be represented as a string.
It works for floating point and exponential numbers also.
let num = 15; num.toString(); //"15" num.toString(2); //"1111" (binary) num.toString(8); //"17" (octa) num.toString(16); //"f" (hexa) num = 15.55; num.toString(); //"15.55" num = 15e10; num.toString(); //"150000000000"
By concatenating with empty string ""
This the most simplest method which can be used to convert a int to string in javascript.
As javascript is loosely typed language when we concatenate a number with string it converts the number to string.
15 + '' // "15"; 15.55 + '' // "15.55"; 15e10 + '' // "150000000000"
As you can see we can also convert floating point and exponential numbers.