├── .bookignore ├── .gitbook └── assets │ ├── async_await.png │ └── intro.png ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── LANGS.md ├── LICENSE ├── README.md ├── _book ├── .bookignore ├── .gitbook │ └── assets │ │ ├── async_await.png │ │ └── intro.png ├── .github │ └── ISSUE_TEMPLATE │ │ ├── bug_report.md │ │ └── feature_request.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── README.md ├── book.epub ├── cover.jpg ├── docker-compose.yml ├── en │ ├── arrays │ │ ├── for-each.html │ │ ├── index.html │ │ ├── indices.html │ │ ├── join.html │ │ ├── length.html │ │ ├── map.html │ │ ├── pop.html │ │ ├── push.html │ │ ├── shift.html │ │ ├── sort.html │ │ ├── spread.html │ │ └── unshift.html │ ├── basics │ │ ├── comments.html │ │ ├── equality.html │ │ ├── index.html │ │ ├── types.html │ │ └── variables.html │ ├── browser-object-model-bom │ │ ├── cookies.html │ │ ├── history.html │ │ ├── index.html │ │ ├── location.html │ │ ├── navigator.html │ │ ├── popup.html │ │ ├── screen.html │ │ └── window.html │ ├── classes │ │ ├── access-modifiers.html │ │ ├── index.html │ │ ├── inheritance.html │ │ └── static.html │ ├── conditional │ │ ├── comparators.html │ │ ├── concatenate.html │ │ ├── else.html │ │ ├── if.html │ │ ├── index.html │ │ └── switch.html │ ├── date-and-time.html │ ├── error-handling │ │ ├── README.md │ │ ├── try...-catch.html │ │ └── try...catch...finally.html │ ├── events.html │ ├── exercises │ │ ├── README.md │ │ ├── concatenation.html │ │ ├── conditional-statements.html │ │ ├── console.html │ │ ├── constants.html │ │ ├── fizzbuzz-problem.html │ │ ├── functions.html │ │ ├── get-the-titles.html │ │ ├── multiplication.html │ │ ├── objects.html │ │ └── user-input-variables.html │ ├── functions │ │ ├── higher-order.html │ │ └── index.html │ ├── index.html │ ├── json.html │ ├── loops │ │ ├── dowhile.html │ │ ├── for.html │ │ ├── index.html │ │ └── while.html │ ├── miscellaneous │ │ ├── README.md │ │ ├── hoisting.html │ │ └── template-literals.html │ ├── modules.html │ ├── numbers │ │ ├── advanced.html │ │ ├── index.html │ │ ├── math.html │ │ └── operators.html │ ├── objects │ │ ├── delete.html │ │ ├── enumeration.html │ │ ├── index.html │ │ ├── mutable.html │ │ ├── properties.html │ │ ├── prototype.html │ │ └── reference.html │ ├── promise-async-await │ │ ├── README.md │ │ ├── async-await.html │ │ └── promise.html │ ├── regular-expression.html │ ├── search_index.json │ ├── sitemap.xml │ ├── strings │ │ ├── concat.html │ │ ├── create.html │ │ ├── index.html │ │ ├── length.html │ │ └── replace.html │ └── template-literals │ │ ├── currying.html │ │ ├── debugging.html │ │ ├── global-footprint.html │ │ ├── linked-list │ │ ├── add.html │ │ ├── index.html │ │ ├── pop.html │ │ ├── prepend.html │ │ └── shift.html │ │ └── polyfills-and-transpilers.html ├── favicon.ico ├── gitbook │ ├── @honkit │ │ └── honkit-plugin-highlight │ │ │ ├── ebook.css │ │ │ └── website.css │ ├── fonts │ │ └── fontawesome │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ ├── fontawesome-webfont.woff │ │ │ └── fontawesome-webfont.woff2 │ ├── gitbook-plugin-chapter-fold │ │ ├── chapter-fold.css │ │ └── chapter-fold.js │ ├── gitbook-plugin-edit-link │ │ └── plugin.js │ ├── gitbook-plugin-exercises │ │ ├── ace │ │ │ ├── ace.js │ │ │ ├── ext-chromevox.js │ │ │ ├── ext-elastic_tabstops_lite.js │ │ │ ├── ext-emmet.js │ │ │ ├── ext-error_marker.js │ │ │ ├── ext-keybinding_menu.js │ │ │ ├── ext-language_tools.js │ │ │ ├── ext-modelist.js │ │ │ ├── ext-old_ie.js │ │ │ ├── ext-searchbox.js │ │ │ ├── ext-settings_menu.js │ │ │ ├── ext-spellcheck.js │ │ │ ├── ext-split.js │ │ │ ├── ext-static_highlight.js │ │ │ ├── ext-statusbar.js │ │ │ ├── ext-textarea.js │ │ │ ├── ext-themelist.js │ │ │ ├── ext-whitespace.js │ │ │ ├── keybinding-emacs.js │ │ │ ├── keybinding-vim.js │ │ │ ├── mode-abap.js │ │ │ ├── mode-actionscript.js │ │ │ ├── mode-ada.js │ │ │ ├── mode-apache_conf.js │ │ │ ├── mode-asciidoc.js │ │ │ ├── mode-assembly_x86.js │ │ │ ├── mode-autohotkey.js │ │ │ ├── mode-batchfile.js │ │ │ ├── mode-c9search.js │ │ │ ├── mode-c_cpp.js │ │ │ ├── mode-cirru.js │ │ │ ├── mode-clojure.js │ │ │ ├── mode-cobol.js │ │ │ ├── mode-coffee.js │ │ │ ├── mode-coldfusion.js │ │ │ ├── mode-csharp.js │ │ │ ├── mode-css.js │ │ │ ├── mode-curly.js │ │ │ ├── mode-d.js │ │ │ ├── mode-dart.js │ │ │ ├── mode-diff.js │ │ │ ├── mode-django.js │ │ │ ├── mode-dot.js │ │ │ ├── mode-ejs.js │ │ │ ├── mode-erlang.js │ │ │ ├── mode-forth.js │ │ │ ├── mode-ftl.js │ │ │ ├── mode-gherkin.js │ │ │ ├── mode-glsl.js │ │ │ ├── mode-golang.js │ │ │ ├── mode-groovy.js │ │ │ ├── mode-haml.js │ │ │ ├── mode-handlebars.js │ │ │ ├── mode-haskell.js │ │ │ ├── mode-haxe.js │ │ │ ├── mode-html.js │ │ │ ├── mode-html_completions.js │ │ │ ├── mode-html_ruby.js │ │ │ ├── mode-ini.js │ │ │ ├── mode-jack.js │ │ │ ├── mode-jade.js │ │ │ ├── mode-java.js │ │ │ ├── mode-javascript.js │ │ │ ├── mode-json.js │ │ │ ├── mode-jsoniq.js │ │ │ ├── mode-jsp.js │ │ │ ├── mode-jsx.js │ │ │ ├── mode-julia.js │ │ │ ├── mode-latex.js │ │ │ ├── mode-less.js │ │ │ ├── mode-liquid.js │ │ │ ├── mode-lisp.js │ │ │ ├── mode-livescript.js │ │ │ ├── mode-logiql.js │ │ │ ├── mode-lsl.js │ │ │ ├── mode-lua.js │ │ │ ├── mode-luapage.js │ │ │ ├── mode-lucene.js │ │ │ ├── mode-makefile.js │ │ │ ├── mode-markdown.js │ │ │ ├── mode-matlab.js │ │ │ ├── mode-mel.js │ │ │ ├── mode-mushcode.js │ │ │ ├── mode-mushcode_high_rules.js │ │ │ ├── mode-mysql.js │ │ │ ├── mode-nix.js │ │ │ ├── mode-objectivec.js │ │ │ ├── mode-ocaml.js │ │ │ ├── mode-pascal.js │ │ │ ├── mode-perl.js │ │ │ ├── mode-pgsql.js │ │ │ ├── mode-php.js │ │ │ ├── mode-plain_text.js │ │ │ ├── mode-powershell.js │ │ │ ├── mode-prolog.js │ │ │ ├── mode-properties.js │ │ │ ├── mode-protobuf.js │ │ │ ├── mode-python.js │ │ │ ├── mode-r.js │ │ │ ├── mode-rdoc.js │ │ │ ├── mode-rhtml.js │ │ │ ├── mode-ruby.js │ │ │ ├── mode-rust.js │ │ │ ├── mode-sass.js │ │ │ ├── mode-scad.js │ │ │ ├── mode-scala.js │ │ │ ├── mode-scheme.js │ │ │ ├── mode-scss.js │ │ │ ├── mode-sh.js │ │ │ ├── mode-sjs.js │ │ │ ├── mode-smarty.js │ │ │ ├── mode-snippets.js │ │ │ ├── mode-soy_template.js │ │ │ ├── mode-space.js │ │ │ ├── mode-sql.js │ │ │ ├── mode-stylus.js │ │ │ ├── mode-svg.js │ │ │ ├── mode-tcl.js │ │ │ ├── mode-tex.js │ │ │ ├── mode-text.js │ │ │ ├── mode-textile.js │ │ │ ├── mode-toml.js │ │ │ ├── mode-twig.js │ │ │ ├── mode-typescript.js │ │ │ ├── mode-vbscript.js │ │ │ ├── mode-velocity.js │ │ │ ├── mode-verilog.js │ │ │ ├── mode-vhdl.js │ │ │ ├── mode-xml.js │ │ │ ├── mode-xquery.js │ │ │ ├── mode-yaml.js │ │ │ ├── snippets │ │ │ │ ├── abap.js │ │ │ │ ├── actionscript.js │ │ │ │ ├── ada.js │ │ │ │ ├── apache_conf.js │ │ │ │ ├── asciidoc.js │ │ │ │ ├── assembly_x86.js │ │ │ │ ├── autohotkey.js │ │ │ │ ├── batchfile.js │ │ │ │ ├── c9search.js │ │ │ │ ├── c_cpp.js │ │ │ │ ├── cirru.js │ │ │ │ ├── clojure.js │ │ │ │ ├── cobol.js │ │ │ │ ├── coffee.js │ │ │ │ ├── coldfusion.js │ │ │ │ ├── csharp.js │ │ │ │ ├── css.js │ │ │ │ ├── curly.js │ │ │ │ ├── d.js │ │ │ │ ├── dart.js │ │ │ │ ├── diff.js │ │ │ │ ├── django.js │ │ │ │ ├── dot.js │ │ │ │ ├── ejs.js │ │ │ │ ├── erlang.js │ │ │ │ ├── forth.js │ │ │ │ ├── ftl.js │ │ │ │ ├── gherkin.js │ │ │ │ ├── glsl.js │ │ │ │ ├── golang.js │ │ │ │ ├── groovy.js │ │ │ │ ├── haml.js │ │ │ │ ├── handlebars.js │ │ │ │ ├── haskell.js │ │ │ │ ├── haxe.js │ │ │ │ ├── html.js │ │ │ │ ├── html_completions.js │ │ │ │ ├── html_ruby.js │ │ │ │ ├── ini.js │ │ │ │ ├── jack.js │ │ │ │ ├── jade.js │ │ │ │ ├── java.js │ │ │ │ ├── javascript.js │ │ │ │ ├── json.js │ │ │ │ ├── jsoniq.js │ │ │ │ ├── jsp.js │ │ │ │ ├── jsx.js │ │ │ │ ├── julia.js │ │ │ │ ├── latex.js │ │ │ │ ├── less.js │ │ │ │ ├── liquid.js │ │ │ │ ├── lisp.js │ │ │ │ ├── livescript.js │ │ │ │ ├── logiql.js │ │ │ │ ├── lsl.js │ │ │ │ ├── lua.js │ │ │ │ ├── luapage.js │ │ │ │ ├── lucene.js │ │ │ │ ├── makefile.js │ │ │ │ ├── markdown.js │ │ │ │ ├── matlab.js │ │ │ │ ├── mel.js │ │ │ │ ├── mushcode.js │ │ │ │ ├── mushcode_high_rules.js │ │ │ │ ├── mysql.js │ │ │ │ ├── nix.js │ │ │ │ ├── objectivec.js │ │ │ │ ├── ocaml.js │ │ │ │ ├── pascal.js │ │ │ │ ├── perl.js │ │ │ │ ├── pgsql.js │ │ │ │ ├── php.js │ │ │ │ ├── plain_text.js │ │ │ │ ├── powershell.js │ │ │ │ ├── prolog.js │ │ │ │ ├── properties.js │ │ │ │ ├── protobuf.js │ │ │ │ ├── python.js │ │ │ │ ├── r.js │ │ │ │ ├── rdoc.js │ │ │ │ ├── rhtml.js │ │ │ │ ├── ruby.js │ │ │ │ ├── rust.js │ │ │ │ ├── sass.js │ │ │ │ ├── scad.js │ │ │ │ ├── scala.js │ │ │ │ ├── scheme.js │ │ │ │ ├── scss.js │ │ │ │ ├── sh.js │ │ │ │ ├── sjs.js │ │ │ │ ├── smarty.js │ │ │ │ ├── snippets.js │ │ │ │ ├── soy_template.js │ │ │ │ ├── space.js │ │ │ │ ├── sql.js │ │ │ │ ├── stylus.js │ │ │ │ ├── svg.js │ │ │ │ ├── tcl.js │ │ │ │ ├── tex.js │ │ │ │ ├── text.js │ │ │ │ ├── textile.js │ │ │ │ ├── toml.js │ │ │ │ ├── twig.js │ │ │ │ ├── typescript.js │ │ │ │ ├── vbscript.js │ │ │ │ ├── velocity.js │ │ │ │ ├── verilog.js │ │ │ │ ├── vhdl.js │ │ │ │ ├── xml.js │ │ │ │ ├── xquery.js │ │ │ │ └── yaml.js │ │ │ ├── theme-ambiance.js │ │ │ ├── theme-chaos.js │ │ │ ├── theme-chrome.js │ │ │ ├── theme-clouds.js │ │ │ ├── theme-clouds_midnight.js │ │ │ ├── theme-cobalt.js │ │ │ ├── theme-crimson_editor.js │ │ │ ├── theme-dawn.js │ │ │ ├── theme-dreamweaver.js │ │ │ ├── theme-eclipse.js │ │ │ ├── theme-github.js │ │ │ ├── theme-idle_fingers.js │ │ │ ├── theme-katzenmilch.js │ │ │ ├── theme-kr.js │ │ │ ├── theme-kuroir.js │ │ │ ├── theme-merbivore.js │ │ │ ├── theme-merbivore_soft.js │ │ │ ├── theme-mono_industrial.js │ │ │ ├── theme-monokai.js │ │ │ ├── theme-pastel_on_dark.js │ │ │ ├── theme-solarized_dark.js │ │ │ ├── theme-solarized_light.js │ │ │ ├── theme-terminal.js │ │ │ ├── theme-textmate.js │ │ │ ├── theme-tomorrow.js │ │ │ ├── theme-tomorrow_night.js │ │ │ ├── theme-tomorrow_night_blue.js │ │ │ ├── theme-tomorrow_night_bright.js │ │ │ ├── theme-tomorrow_night_eighties.js │ │ │ ├── theme-twilight.js │ │ │ ├── theme-vibrant_ink.js │ │ │ ├── theme-xcode.js │ │ │ ├── worker-coffee.js │ │ │ ├── worker-css.js │ │ │ ├── worker-html.js │ │ │ ├── worker-javascript.js │ │ │ ├── worker-json.js │ │ │ ├── worker-lua.js │ │ │ ├── worker-php.js │ │ │ └── worker-xquery.js │ │ ├── ebook.css │ │ ├── ebook.html │ │ ├── exercises.css │ │ ├── exercises.js │ │ ├── jsrepl │ │ │ ├── engines │ │ │ │ └── javascript-default.js │ │ │ ├── jsrepl.js │ │ │ ├── langs │ │ │ │ └── javascript │ │ │ │ │ └── jsrepl_js.js │ │ │ ├── sandbox.html │ │ │ └── sandbox.js │ │ └── website.html │ ├── gitbook-plugin-fontsettings │ │ ├── fontsettings.js │ │ └── website.css │ ├── gitbook-plugin-hide-published-with │ │ └── plugin.js │ ├── gitbook-plugin-hints │ │ └── plugin-hints.css │ ├── gitbook-plugin-intopic-toc │ │ ├── anchor.min.js │ │ ├── gumshoe.polyfills.min.js │ │ ├── plugin.js │ │ ├── plugin.js.map │ │ └── style.css │ ├── gitbook-plugin-livereload │ │ └── plugin.js │ ├── gitbook-plugin-lunr │ │ ├── lunr.min.js │ │ └── search-lunr.js │ ├── gitbook-plugin-search │ │ ├── lunr.min.js │ │ ├── search-engine.js │ │ ├── search.css │ │ └── search.js │ ├── gitbook-plugin-sharing │ │ └── buttons.js │ ├── gitbook-plugin-sidebar-ad │ │ └── sidebar-ad.css │ ├── gitbook.js │ ├── honkit-plugin-i18nsettings │ │ └── i18nsettings.js │ ├── images │ │ ├── apple-touch-icon-precomposed-152.png │ │ └── favicon.ico │ ├── style.css │ └── theme.js ├── index.html ├── js.png ├── ne │ ├── arrays │ │ ├── for-each.html │ │ ├── index.html │ │ ├── indices.html │ │ ├── join.html │ │ ├── length.html │ │ ├── map.html │ │ ├── pop.html │ │ ├── push.html │ │ ├── shift.html │ │ ├── sort.html │ │ ├── spread.html │ │ └── unshift.html │ ├── basics │ │ ├── comments.html │ │ ├── equality.html │ │ ├── index.html │ │ ├── types.html │ │ └── variables.html │ ├── browser-object-model-bom │ │ ├── cookies.html │ │ ├── history.html │ │ ├── index.html │ │ ├── location.html │ │ ├── navigator.html │ │ ├── popup.html │ │ ├── screen.html │ │ └── window.html │ ├── classes │ │ ├── access-modifiers.html │ │ ├── index.html │ │ ├── inheritance.html │ │ └── static.html │ ├── conditional │ │ ├── comparators.html │ │ ├── concatenate.html │ │ ├── else.html │ │ ├── if.html │ │ ├── index.html │ │ └── switch.html │ ├── date-and-time.html │ ├── error-handling │ │ ├── README.md │ │ ├── try...-catch.html │ │ └── try...catch...finally.html │ ├── events.html │ ├── exercises │ │ ├── README.md │ │ ├── concatenation.html │ │ ├── conditional-statements.html │ │ ├── console.html │ │ ├── constants.html │ │ ├── fizzbuzz-problem.html │ │ ├── functions.html │ │ ├── get-the-titles.html │ │ ├── multiplication.html │ │ ├── objects.html │ │ └── user-input-variables.html │ ├── functions │ │ ├── higher-order.html │ │ └── index.html │ ├── index.html │ ├── json.html │ ├── loops │ │ ├── dowhile.html │ │ ├── for.html │ │ ├── index.html │ │ └── while.html │ ├── miscellaneous │ │ ├── README.md │ │ ├── hoisting.html │ │ └── template-literals.html │ ├── modules.html │ ├── numbers │ │ ├── advanced.html │ │ ├── index.html │ │ ├── math.html │ │ └── operators.html │ ├── objects │ │ ├── delete.html │ │ ├── enumeration.html │ │ ├── index.html │ │ ├── mutable.html │ │ ├── properties.html │ │ ├── prototype.html │ │ └── reference.html │ ├── promise-async-await │ │ ├── README.md │ │ ├── async-await.html │ │ └── promise.html │ ├── regular-expression.html │ ├── search_index.json │ ├── sitemap.xml │ ├── strings │ │ ├── concat.html │ │ ├── create.html │ │ ├── index.html │ │ ├── length.html │ │ └── replace.html │ └── template-literals │ │ ├── currying.html │ │ ├── debugging.html │ │ ├── global-footprint.html │ │ ├── linked-list │ │ ├── add.html │ │ ├── index.html │ │ ├── pop.html │ │ ├── prepend.html │ │ ├── shift.html │ │ └── translate.json │ │ └── polyfills-and-transpilers.html ├── package.json ├── search_index.json ├── sitemap.xml ├── star_us.gif ├── yarn-error.log └── yarn.lock ├── _layouts ├── layout.html └── website │ ├── header.html │ ├── languages.html │ ├── layout.html │ ├── page.html │ └── summary.html ├── book.epub ├── book.json ├── book.pdf ├── cover.jpg ├── docker-compose.yml ├── en ├── README.md ├── SUMMARY.md ├── arrays │ ├── README.md │ ├── for-each.md │ ├── indices.md │ ├── join.md │ ├── length.md │ ├── map.md │ ├── pop.md │ ├── push.md │ ├── shift.md │ ├── sort.md │ ├── spread.md │ └── unshift.md ├── basics │ ├── README.md │ ├── comments.md │ ├── equality.md │ ├── types.md │ └── variables.md ├── browser-object-model-bom │ ├── README.md │ ├── cookies.md │ ├── history.md │ ├── location.md │ ├── navigator.md │ ├── popup.md │ ├── screen.md │ └── window.md ├── classes │ ├── README.md │ ├── access-modifiers.md │ ├── inheritance.md │ └── static.md ├── conditional │ ├── README.md │ ├── comparators.md │ ├── concatenate.md │ ├── else.md │ ├── if.md │ └── switch.md ├── date-and-time.md ├── error-handling │ ├── README.md │ ├── try...-catch.md │ └── try...catch...finally.md ├── events.md ├── exercises │ ├── README.md │ ├── concatenation.md │ ├── conditional-statements.md │ ├── console.md │ ├── constants.md │ ├── fizzbuzz-problem.md │ ├── functions.md │ ├── get-the-titles.md │ ├── multiplication.md │ ├── objects.md │ └── user-input-variables.md ├── functions │ ├── README.md │ └── higher-order.md ├── json.md ├── loops │ ├── README.md │ ├── dowhile.md │ ├── for.md │ └── while.md ├── miscellaneous │ ├── README.md │ ├── hoisting.md │ └── template-literals.md ├── modules.md ├── numbers │ ├── README.md │ ├── advanced.md │ ├── math.md │ └── operators.md ├── objects │ ├── README.md │ ├── delete.md │ ├── enumeration.md │ ├── mutable.md │ ├── properties.md │ ├── prototype.md │ └── reference.md ├── promise-async-await │ ├── README.md │ ├── async-await.md │ └── promise.md ├── regular-expression.md ├── strings │ ├── README.md │ ├── concat.md │ ├── create.md │ ├── length.md │ └── replace.md └── template-literals │ ├── currying.md │ ├── debugging.md │ ├── global-footprint.md │ ├── linked-list │ ├── README.md │ ├── add.md │ ├── pop.md │ ├── prepend.md │ └── shift.md │ └── polyfills-and-transpilers.md ├── favicon.ico ├── js.png ├── ne ├── README.md ├── SUMMARY.md ├── arrays │ ├── README.md │ ├── for-each.md │ ├── indices.md │ ├── join.md │ ├── length.md │ ├── map.md │ ├── pop.md │ ├── push.md │ ├── shift.md │ ├── sort.md │ ├── spread.md │ └── unshift.md ├── basics │ ├── README.md │ ├── comments.md │ ├── equality.md │ ├── types.md │ └── variables.md ├── book.json ├── browser-object-model-bom │ ├── README.md │ ├── cookies.md │ ├── history.md │ ├── location.md │ ├── navigator.md │ ├── popup.md │ ├── screen.md │ └── window.md ├── classes │ ├── README.md │ ├── access-modifiers.md │ ├── inheritance.md │ └── static.md ├── conditional │ ├── README.md │ ├── comparators.md │ ├── concatenate.md │ ├── else.md │ ├── if.md │ └── switch.md ├── date-and-time.md ├── error-handling │ ├── README.md │ ├── try...-catch.md │ └── try...catch...finally.md ├── events.md ├── exercises │ ├── README.md │ ├── concatenation.md │ ├── conditional-statements.md │ ├── console.md │ ├── constants.md │ ├── fizzbuzz-problem.md │ ├── functions.md │ ├── get-the-titles.md │ ├── multiplication.md │ ├── objects.md │ └── user-input-variables.md ├── functions │ ├── README.md │ └── higher-order.md ├── json.md ├── loops │ ├── README.md │ ├── dowhile.md │ ├── for.md │ └── while.md ├── miscellaneous │ ├── README.md │ ├── hoisting.md │ └── template-literals.md ├── modules.md ├── numbers │ ├── README.md │ ├── advanced.md │ ├── math.md │ └── operators.md ├── objects │ ├── README.md │ ├── delete.md │ ├── enumeration.md │ ├── mutable.md │ ├── properties.md │ ├── prototype.md │ └── reference.md ├── promise-async-await │ ├── README.md │ ├── async-await.md │ └── promise.md ├── regular-expression.md ├── strings │ ├── README.md │ ├── concat.md │ ├── create.md │ ├── length.md │ └── replace.md └── template-literals │ ├── currying.md │ ├── debugging.md │ ├── global-footprint.md │ ├── linked-list │ ├── README.md │ ├── add.md │ ├── pop.md │ ├── prepend.md │ └── shift.md │ └── polyfills-and-transpilers.md ├── package.json ├── star_us.gif ├── yarn-error.log └── yarn.lock /.bookignore: -------------------------------------------------------------------------------- 1 | *.js 2 | *.pdf -------------------------------------------------------------------------------- /.gitbook/assets/async_await.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/.gitbook/assets/async_await.png -------------------------------------------------------------------------------- /.gitbook/assets/intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/.gitbook/assets/intro.png -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .grunt 3 | .vscode 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:16 2 | 3 | # Create app directory 4 | WORKDIR /usr/src/app 5 | 6 | # Install app dependencies 7 | # A wildcard is used to ensure both package.json AND package-lock.json are copied 8 | # where available (npm@5+) 9 | COPY package*.json ./ 10 | 11 | RUN npm install 12 | # If you are building your code for production 13 | # RUN npm ci --omit=dev 14 | RUN npm install -g honkit@4.0.4 15 | # Bundle app source 16 | COPY . . -------------------------------------------------------------------------------- /LANGS.md: -------------------------------------------------------------------------------- 1 | * [English](en/) 2 | * [नेपाली](ne/) 3 | -------------------------------------------------------------------------------- /_book/.bookignore: -------------------------------------------------------------------------------- 1 | *.js 2 | *.pdf -------------------------------------------------------------------------------- /_book/.gitbook/assets/async_await.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/.gitbook/assets/async_await.png -------------------------------------------------------------------------------- /_book/.gitbook/assets/intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/.gitbook/assets/intro.png -------------------------------------------------------------------------------- /_book/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /_book/.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /_book/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .grunt 3 | .vscode 4 | -------------------------------------------------------------------------------- /_book/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:16 2 | 3 | # Create app directory 4 | WORKDIR /usr/src/app 5 | 6 | # Install app dependencies 7 | # A wildcard is used to ensure both package.json AND package-lock.json are copied 8 | # where available (npm@5+) 9 | COPY package*.json ./ 10 | 11 | RUN npm install 12 | # If you are building your code for production 13 | # RUN npm ci --omit=dev 14 | RUN npm install -g honkit@4.0.4 15 | # Bundle app source 16 | COPY . . -------------------------------------------------------------------------------- /_book/book.epub: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/book.epub -------------------------------------------------------------------------------- /_book/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/cover.jpg -------------------------------------------------------------------------------- /_book/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | book: 4 | tty: true 5 | restart: always 6 | build: 7 | context: . 8 | dockerfile: ./Dockerfile 9 | ports: 10 | - "4000:4000" 11 | - "35729:35729" 12 | volumes: 13 | - .:/usr/src/app 14 | - modules:/usr/src/app/node_modules 15 | command: npm start 16 | working_dir: /usr/src/app 17 | volumes: 18 | modules: 19 | driver: local -------------------------------------------------------------------------------- /_book/en/error-handling/README.md: -------------------------------------------------------------------------------- 1 | # Error Handling 2 | 3 | -------------------------------------------------------------------------------- /_book/en/exercises/README.md: -------------------------------------------------------------------------------- 1 | # Exercises 2 | 3 | -------------------------------------------------------------------------------- /_book/en/miscellaneous/README.md: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | 3 | -------------------------------------------------------------------------------- /_book/en/promise-async-await/README.md: -------------------------------------------------------------------------------- 1 | # Promise, async/await 2 | 3 | -------------------------------------------------------------------------------- /_book/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/favicon.ico -------------------------------------------------------------------------------- /_book/gitbook/fonts/fontawesome/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/gitbook/fonts/fontawesome/FontAwesome.otf -------------------------------------------------------------------------------- /_book/gitbook/fonts/fontawesome/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/gitbook/fonts/fontawesome/fontawesome-webfont.eot -------------------------------------------------------------------------------- /_book/gitbook/fonts/fontawesome/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/gitbook/fonts/fontawesome/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff -------------------------------------------------------------------------------- /_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-chapter-fold/chapter-fold.css: -------------------------------------------------------------------------------- 1 | .book .book-summary .chapter > .articles { 2 | overflow: hidden; 3 | max-height: 0px; 4 | } 5 | 6 | .book .book-summary .chapter.expanded > .articles { 7 | max-height: 9999px; 8 | } 9 | 10 | .book .book-summary .exc-trigger { 11 | position: absolute; 12 | left: 12px; 13 | top: 12px; 14 | } 15 | 16 | .book .book-summary ul.summary li a, 17 | .book .book-summary ul.summary li span { 18 | padding-left: 30px; 19 | } 20 | 21 | .book .book-summary .exc-trigger:before { 22 | content: "\f105"; 23 | } 24 | 25 | .book .book-summary .expanded > a .exc-trigger:before, 26 | .book .book-summary .expanded > span .exc-trigger:before { 27 | content: "\f107"; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-edit-link/plugin.js: -------------------------------------------------------------------------------- 1 | require(["gitbook", "jQuery"], function(gitbook, $) { 2 | gitbook.events.bind('start', function (e, config) { 3 | var conf = config['edit-link']; 4 | var label = conf.label; 5 | var base = conf.base; 6 | var lang = gitbook.state.innerLanguage; 7 | if (lang) { 8 | // label can be a unique string for multi-languages site 9 | if (typeof label === 'object') label = label[lang]; 10 | 11 | lang = lang + '/'; 12 | } 13 | 14 | // Add slash at the end if not present 15 | if (base.slice(-1) != "/") { 16 | base = base + "/"; 17 | } 18 | 19 | gitbook.toolbar.createButton({ 20 | icon: 'fa fa-edit', 21 | text: label, 22 | onClick: function() { 23 | var filepath = gitbook.state.filepath; 24 | 25 | window.open(base + lang + filepath); 26 | } 27 | }); 28 | }); 29 | 30 | }); -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/ext-error_marker.js: -------------------------------------------------------------------------------- 1 | (function(){ace.require(["ace/ext/error_marker"],function(){})})() -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/ext-spellcheck.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/ext/spellcheck",["require","exports","module","ace/lib/event","ace/editor","ace/config"],function(e,t,n){var r=e("../lib/event");t.contextMenuHandler=function(e){var t=e.target,n=t.textInput.getElement();if(!t.selection.isEmpty())return;var i=t.getCursorPosition(),s=t.session.getWordRange(i.row,i.column),o=t.session.getTextRange(s);t.session.tokenRe.lastIndex=0;if(!t.session.tokenRe.test(o))return;var u="\x01\x01",a=o+" "+u;n.value=a,n.setSelectionRange(o.length,o.length+1),n.setSelectionRange(0,0),n.setSelectionRange(0,o.length);var f=!1;r.addListener(n,"keydown",function l(){r.removeListener(n,"keydown",l),f=!0}),t.textInput.setInputHandler(function(e){console.log(e,a,n.selectionStart,n.selectionEnd);if(e==a)return"";if(e.lastIndexOf(a,0)===0)return e.slice(a.length);if(e.substr(n.selectionEnd)==a)return e.slice(0,-a.length);if(e.slice(-2)==u){var r=e.slice(0,-2);if(r.slice(-1)==" ")return f?r.substring(0,n.selectionEnd):(r=r.slice(0,-1),t.session.replace(s,r),"")}return e})};var i=e("../editor").Editor;e("../config").defineOptions(i.prototype,"editor",{spellcheck:{set:function(e){var n=this.textInput.getElement();n.spellcheck=!!e,e?this.on("nativecontextmenu",t.contextMenuHandler):this.removeListener("nativecontextmenu",t.contextMenuHandler)},value:!0}})}),function(){ace.require(["ace/ext/spellcheck"],function(){})}() -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/ext-statusbar.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/ext/statusbar",["require","exports","module","ace/lib/dom","ace/lib/lang"],function(e,t,n){var r=e("ace/lib/dom"),i=e("ace/lib/lang"),s=function(e,t){this.element=r.createElement("div"),this.element.className="ace_status-indicator",this.element.style.cssText="display: inline-block;",t.appendChild(this.element);var n=i.delayedCall(function(){this.updateStatus(e)}.bind(this));e.on("changeStatus",function(){n.schedule(100)}),e.on("changeSelection",function(){n.schedule(100)})};(function(){this.updateStatus=function(e){function n(e,n){e&&t.push(e,n||"|")}var t=[];e.$vimModeHandler?n(e.$vimModeHandler.getStatusText()):e.commands.recording&&n("REC");var r=e.selection.lead;n(r.row+":"+r.column," ");if(!e.selection.isEmpty()){var i=e.getSelectionRange();n("("+(i.end.row-i.start.row)+":"+(i.end.column-i.start.column)+")")}t.pop(),this.element.textContent=t.join("")}}).call(s.prototype),t.StatusBar=s}),function(){ace.require(["ace/ext/statusbar"],function(){})}() -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/ext-themelist.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/ext/themelist",["require","exports","module"],function(e,t,n){var r=[["Chrome"],["Clouds"],["Crimson Editor"],["Dawn"],["Dreamweaver"],["Eclipse"],["GitHub"],["Solarized Light"],["TextMate"],["Tomorrow"],["XCode"],["Kuroir"],["KatzenMilch"],["Ambiance","ambiance","dark"],["Chaos","chaos","dark"],["Clouds Midnight","clouds_midnight","dark"],["Cobalt","cobalt","dark"],["idle Fingers","idle_fingers","dark"],["krTheme","kr_theme","dark"],["Merbivore","merbivore","dark"],["Merbivore Soft","merbivore_soft","dark"],["Mono Industrial","mono_industrial","dark"],["Monokai","monokai","dark"],["Pastel on dark","pastel_on_dark","dark"],["Solarized Dark","solarized_dark","dark"],["Terminal","terminal","dark"],["Tomorrow Night","tomorrow_night","dark"],["Tomorrow Night Blue","tomorrow_night_blue","dark"],["Tomorrow Night Bright","tomorrow_night_bright","dark"],["Tomorrow Night 80s","tomorrow_night_eighties","dark"],["Twilight","twilight","dark"],["Vibrant Ink","vibrant_ink","dark"]];t.themesByName={},t.themes=r.map(function(e){var n=e[1]||e[0].replace(/ /g,"_").toLowerCase(),r={caption:e[0],theme:"ace/theme/"+n,isDark:e[2]=="dark",name:n};return t.themesByName[n]=r,r})}),function(){ace.require(["ace/ext/themelist"],function(){})}() -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/mode-ada.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/mode/ada",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/ada_highlight_rules","ace/range"],function(e,t,n){var r=e("../lib/oop"),i=e("./text").Mode,s=e("../tokenizer").Tokenizer,o=e("./ada_highlight_rules").AdaHighlightRules,u=e("../range").Range,a=function(){this.HighlightRules=o};r.inherits(a,i),function(){this.lineCommentStart="--",this.$id="ace/mode/ada"}.call(a.prototype),t.Mode=a}),ace.define("ace/mode/ada_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){var e="abort|else|new|return|abs|elsif|not|reverse|abstract|end|null|accept|entry|select|access|exception|of|separate|aliased|exit|or|some|all|others|subtype|and|for|out|synchronized|array|function|overriding|at|tagged|generic|package|task|begin|goto|pragma|terminate|body|private|then|if|procedure|type|case|in|protected|constant|interface|until||is|raise|use|declare|range|delay|limited|record|when|delta|loop|rem|while|digits|renames|with|do|mod|requeue|xor",t="true|false|null",n="count|min|max|avg|sum|rank|now|coalesce|main",r=this.createKeywordMapper({"support.function":n,keyword:e,"constant.language":t},"identifier",!0);this.$rules={start:[{token:"comment",regex:"--.*$"},{token:"string",regex:'".*?"'},{token:"string",regex:"'.*?'"},{token:"constant.numeric",regex:"[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"},{token:r,regex:"[a-zA-Z_$][a-zA-Z0-9_$]*\\b"},{token:"keyword.operator",regex:"\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="},{token:"paren.lparen",regex:"[\\(]"},{token:"paren.rparen",regex:"[\\)]"},{token:"text",regex:"\\s+"}]}};r.inherits(s,i),t.AdaHighlightRules=s}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/mode-lucene.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/mode/lucene",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/lucene_highlight_rules"],function(e,t,n){var r=e("../lib/oop"),i=e("./text").Mode,s=e("../tokenizer").Tokenizer,o=e("./lucene_highlight_rules").LuceneHighlightRules,u=function(){this.$tokenizer=new s((new o).getRules())};r.inherits(u,i),function(){this.$id="ace/mode/lucene"}.call(u.prototype),t.Mode=u}),ace.define("ace/mode/lucene_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"],function(e,t,n){var r=e("../lib/oop"),i=e("../lib/lang"),s=e("./text_highlight_rules").TextHighlightRules,o=function(){this.$rules={start:[{token:"constant.character.negation",regex:"[\\-]"},{token:"constant.character.interro",regex:"[\\?]"},{token:"constant.character.asterisk",regex:"[\\*]"},{token:"constant.character.proximity",regex:"~[0-9]+\\b"},{token:"keyword.operator",regex:"(?:AND|OR|NOT)\\b"},{token:"paren.lparen",regex:"[\\(]"},{token:"paren.rparen",regex:"[\\)]"},{token:"keyword",regex:"[\\S]+:"},{token:"string",regex:'".*?"'},{token:"text",regex:"\\s+"}]}};r.inherits(o,s),t.LuceneHighlightRules=o}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/mode-plain_text.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/mode/plain_text",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour"],function(e,t,n){var r=e("../lib/oop"),i=e("./text").Mode,s=e("../tokenizer").Tokenizer,o=e("./text_highlight_rules").TextHighlightRules,u=e("./behaviour").Behaviour,a=function(){this.HighlightRules=o,this.$behaviour=new u};r.inherits(a,i),function(){this.type="text",this.getNextLineIndent=function(e,t,n){return""},this.$id="ace/mode/plain_text"}.call(a.prototype),t.Mode=a}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/mode-properties.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/mode/properties",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/properties_highlight_rules"],function(e,t,n){var r=e("../lib/oop"),i=e("./text").Mode,s=e("../tokenizer").Tokenizer,o=e("./properties_highlight_rules").PropertiesHighlightRules,u=function(){this.HighlightRules=o};r.inherits(u,i),function(){this.$id="ace/mode/properties"}.call(u.prototype),t.Mode=u}),ace.define("ace/mode/properties_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){var e=/\\u[0-9a-fA-F]{4}|\\/;this.$rules={start:[{token:"comment",regex:/[!#].*$/},{token:"keyword",regex:/[=:]$/},{token:"keyword",regex:/[=:]/,next:"value"},{token:"constant.language.escape",regex:e},{defaultToken:"variable"}],value:[{regex:/\\$/,token:"string",next:"value"},{regex:/$/,token:"string",next:"start"},{token:"constant.language.escape",regex:e},{defaultToken:"string"}]}};r.inherits(s,i),t.PropertiesHighlightRules=s}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/mode-scheme.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/mode/scheme",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/scheme_highlight_rules"],function(e,t,n){var r=e("../lib/oop"),i=e("./text").Mode,s=e("../tokenizer").Tokenizer,o=e("./scheme_highlight_rules").SchemeHighlightRules,u=function(){this.HighlightRules=o};r.inherits(u,i),function(){this.lineCommentStart=";",this.$id="ace/mode/scheme"}.call(u.prototype),t.Mode=u}),ace.define("ace/mode/scheme_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){var e="case|do|let|loop|if|else|when",t="eq?|eqv?|equal?|and|or|not|null?",n="#t|#f",r="cons|car|cdr|cond|lambda|lambda*|syntax-rules|format|set!|quote|eval|append|list|list?|member?|load",i=this.createKeywordMapper({"keyword.control":e,"keyword.operator":t,"constant.language":n,"support.function":r},"identifier",!0);this.$rules={start:[{token:"comment",regex:";.*$"},{token:["storage.type.function-type.scheme","text","entity.name.function.scheme"],regex:"(?:\\b(?:(define|define-syntax|define-macro))\\b)(\\s+)((?:\\w|\\-|\\!|\\?)*)"},{token:"punctuation.definition.constant.character.scheme",regex:"#:\\S+"},{token:["punctuation.definition.variable.scheme","variable.other.global.scheme","punctuation.definition.variable.scheme"],regex:"(\\*)(\\S*)(\\*)"},{token:"constant.numeric",regex:"#[xXoObB][0-9a-fA-F]+"},{token:"constant.numeric",regex:"[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?"},{token:i,regex:"[a-zA-Z_#][a-zA-Z0-9_\\-\\?\\!\\*]*"},{token:"string",regex:'"(?=.)',next:"qqstring"}],qqstring:[{token:"constant.character.escape.scheme",regex:"\\\\."},{token:"string",regex:'[^"\\\\]+',merge:!0},{token:"string",regex:"\\\\$",next:"qqstring",merge:!0},{token:"string",regex:'"|$',next:"start",merge:!0}]}};r.inherits(s,i),t.SchemeHighlightRules=s}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/mode-sql.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/mode/sql",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/sql_highlight_rules","ace/range"],function(e,t,n){var r=e("../lib/oop"),i=e("./text").Mode,s=e("../tokenizer").Tokenizer,o=e("./sql_highlight_rules").SqlHighlightRules,u=e("../range").Range,a=function(){this.HighlightRules=o};r.inherits(a,i),function(){this.lineCommentStart="--",this.$id="ace/mode/sql"}.call(a.prototype),t.Mode=a}),ace.define("ace/mode/sql_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){var e="select|insert|update|delete|from|where|and|or|group|by|order|limit|offset|having|as|case|when|else|end|type|left|right|join|on|outer|desc|asc",t="true|false|null",n="count|min|max|avg|sum|rank|now|coalesce",r=this.createKeywordMapper({"support.function":n,keyword:e,"constant.language":t},"identifier",!0);this.$rules={start:[{token:"comment",regex:"--.*$"},{token:"comment",start:"/\\*",end:"\\*/"},{token:"string",regex:'".*?"'},{token:"string",regex:"'.*?'"},{token:"constant.numeric",regex:"[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"},{token:r,regex:"[a-zA-Z_$][a-zA-Z0-9_$]*\\b"},{token:"keyword.operator",regex:"\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="},{token:"paren.lparen",regex:"[\\(]"},{token:"paren.rparen",regex:"[\\)]"},{token:"text",regex:"\\s+"}]},this.normalizeRules()};r.inherits(s,i),t.SqlHighlightRules=s}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/mode-text.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/gitbook/gitbook-plugin-exercises/ace/mode-text.js -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/abap.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/abap",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="abap"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/ada.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/ada",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="ada"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/apache_conf.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/apache_conf",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="apache_conf"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/asciidoc.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/asciidoc",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="asciidoc"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/assembly_x86.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/assembly_x86",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="assembly_x86"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/autohotkey.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/autohotkey",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="autohotkey"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/batchfile.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/batchfile",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="batchfile"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/c9search.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/c9search",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="c9search"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/cirru.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/cirru",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="cirru"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/cobol.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/cobol",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="cobol"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/coldfusion.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/coldfusion",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="coldfusion"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/csharp.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/csharp",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="csharp"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/curly.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/curly",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="curly"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/d.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/d",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="d"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/dart.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/dart",["require","exports","module"],function(e,t,n){t.snippetText="snippet lib\n library ${1};\n ${2}\nsnippet im\n import '${1}';\n ${2}\nsnippet pa\n part '${1}';\n ${2}\nsnippet pao\n part of ${1};\n ${2}\nsnippet main\n void main() {\n ${1:/* code */}\n }\nsnippet st\n static ${1}\nsnippet fi\n final ${1}\nsnippet re\n return ${1}\nsnippet br\n break;\nsnippet th\n throw ${1}\nsnippet cl\n class ${1:`Filename(\"\", \"untitled\")`} ${2}\nsnippet imp\n implements ${1}\nsnippet ext\n extends ${1}\nsnippet if\n if (${1:true}) {\n ${2}\n }\nsnippet ife\n if (${1:true}) {\n ${2}\n } else {\n ${3}\n }\nsnippet el\n else\nsnippet sw\n switch (${1}) {\n ${2}\n }\nsnippet cs\n case ${1}:\n ${2}\nsnippet de\n default:\n ${1}\nsnippet for\n for (var ${2:i} = 0, len = ${1:things}.length; $2 < len; ${3:++}$2) {\n ${4:$1[$2]}\n }\nsnippet fore\n for (final ${2:item} in ${1:itemList}) {\n ${3:/* code */}\n }\nsnippet wh\n while (${1:/* condition */}) {\n ${2:/* code */}\n }\nsnippet dowh\n do {\n ${2:/* code */}\n } while (${1:/* condition */});\nsnippet as\n assert(${1:/* condition */});\nsnippet try\n try {\n ${2}\n } catch (${1:Exception e}) {\n }\nsnippet tryf\n try {\n ${2}\n } catch (${1:Exception e}) {\n } finally {\n }\n",t.scope="dart"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/diff.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/diff",["require","exports","module"],function(e,t,n){t.snippetText='# DEP-3 (http://dep.debian.net/deps/dep3/) style patch header\nsnippet header DEP-3 style header\n Description: ${1}\n Origin: ${2:vendor|upstream|other}, ${3:url of the original patch}\n Bug: ${4:url in upstream bugtracker}\n Forwarded: ${5:no|not-needed|url}\n Author: ${6:`g:snips_author`}\n Reviewed-by: ${7:name and email}\n Last-Update: ${8:`strftime("%Y-%m-%d")`}\n Applied-Upstream: ${9:upstream version|url|commit}\n\n',t.scope="diff"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/dot.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/dot",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="dot"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/ejs.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/ejs",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="ejs"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/forth.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/forth",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="forth"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/ftl.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/ftl",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="ftl"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/gherkin.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/gherkin",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="gherkin"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/glsl.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/glsl",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="glsl"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/golang.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/golang",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="golang"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/groovy.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/groovy",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="groovy"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/haml.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/haml",["require","exports","module"],function(e,t,n){t.snippetText="snippet t\n %table\n %tr\n %th\n ${1:headers}\n %tr\n %td\n ${2:headers}\nsnippet ul\n %ul\n %li\n ${1:item}\n %li\nsnippet =rp\n = render :partial => '${1:partial}'\nsnippet =rpl\n = render :partial => '${1:partial}', :locals => {}\nsnippet =rpc\n = render :partial => '${1:partial}', :collection => @$1\n\n",t.scope="haml"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/handlebars.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/handlebars",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="handlebars"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/haxe.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/haxe",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="haxe"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/html_completions.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/html_completions",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="html_completions"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/html_ruby.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/html_ruby",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="html_ruby"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/ini.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/ini",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="ini"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/jack.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/jack",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="jack"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/jade.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/jade",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="jade"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/json.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/json",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="json"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/jsoniq.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/jsoniq",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="jsoniq"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/jsx.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/jsx",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="jsx"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/julia.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/julia",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="julia"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/latex.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/latex",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="latex"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/less.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/less",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="less"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/liquid.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/liquid",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="liquid"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/lisp.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/lisp",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="lisp"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/livescript.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/livescript",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="livescript"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/logiql.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/logiql",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="logiql"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/lua.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/lua",["require","exports","module"],function(e,t,n){t.snippetText="snippet #!\n #!/usr/bin/env lua\n $1\nsnippet local\n local ${1:x} = ${2:1}\nsnippet fun\n function ${1:fname}(${2:...})\n ${3:-- body}\n end\nsnippet for\n for ${1:i}=${2:1},${3:10} do\n ${4:print(i)}\n end\nsnippet forp\n for ${1:i},${2:v} in pairs(${3:table_name}) do\n ${4:-- body}\n end\nsnippet fori\n for ${1:i},${2:v} in ipairs(${3:table_name}) do\n ${4:-- body}\n end\n",t.scope="lua"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/luapage.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/luapage",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="luapage"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/lucene.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/lucene",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="lucene"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/makefile.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/makefile",["require","exports","module"],function(e,t,n){t.snippetText="snippet ifeq\n ifeq (${1:cond0},${2:cond1})\n ${3:code}\n endif\n",t.scope="makefile"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/matlab.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/matlab",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="matlab"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/mel.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/mel",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="mel"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/mushcode.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/mushcode",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="mushcode"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/mushcode_high_rules.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/mushcode_high_rules",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="mushcode_high_rules"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/mysql.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/mysql",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="mysql"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/nix.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/nix",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="nix"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/objectivec.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/objectivec",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="objectivec"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/ocaml.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/ocaml",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="ocaml"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/pascal.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/pascal",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="pascal"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/pgsql.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/pgsql",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="pgsql"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/plain_text.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/plain_text",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="plain_text"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/powershell.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/powershell",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="powershell"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/prolog.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/prolog",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="prolog"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/properties.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/properties",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="properties"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/protobuf.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/protobuf",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="protobuf"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/rdoc.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/rdoc",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="rdoc"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/rhtml.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/rhtml",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="rhtml"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/rust.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/rust",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="rust"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/sass.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/sass",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="sass"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/scad.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/scad",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="scad"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/scala.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/scala",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="scala"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/scheme.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/scheme",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="scheme"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/scss.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/scss",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="scss"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/sjs.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/sjs",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="sjs"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/smarty.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/smarty",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="smarty"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/snippets.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/snippets",["require","exports","module"],function(e,t,n){t.snippetText="# snippets for making snippets :)\nsnippet snip\n snippet ${1:trigger}\n ${2}\nsnippet msnip\n snippet ${1:trigger} ${2:description}\n ${3}\nsnippet v\n {VISUAL}\n",t.scope="snippets"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/soy_template.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/soy_template",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="soy_template"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/space.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/space",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="space"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/sql.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/sql",["require","exports","module"],function(e,t,n){t.snippetText="snippet tbl\n create table ${1:table} (\n ${2:columns}\n );\nsnippet col\n ${1:name} ${2:type} ${3:default ''} ${4:not null}\nsnippet ccol\n ${1:name} varchar2(${2:size}) ${3:default ''} ${4:not null}\nsnippet ncol\n ${1:name} number ${3:default 0} ${4:not null}\nsnippet dcol\n ${1:name} date ${3:default sysdate} ${4:not null}\nsnippet ind\n create index ${3:$1_$2} on ${1:table}(${2:column});\nsnippet uind\n create unique index ${1:name} on ${2:table}(${3:column});\nsnippet tblcom\n comment on table ${1:table} is '${2:comment}';\nsnippet colcom\n comment on column ${1:table}.${2:column} is '${3:comment}';\nsnippet addcol\n alter table ${1:table} add (${2:column} ${3:type});\nsnippet seq\n create sequence ${1:name} start with ${2:1} increment by ${3:1} minvalue ${4:1};\nsnippet s*\n select * from ${1:table}\n",t.scope="sql"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/stylus.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/stylus",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="stylus"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/svg.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/svg",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="svg"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/tcl.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/tcl",["require","exports","module"],function(e,t,n){t.snippetText="# #!/usr/bin/env tclsh\nsnippet #!\n #!/usr/bin/env tclsh\n \n# Process\nsnippet pro\n proc ${1:function_name} {${2:args}} {\n ${3:#body ...}\n }\n#xif\nsnippet xif\n ${1:expr}? ${2:true} : ${3:false}\n# Conditional\nsnippet if\n if {${1}} {\n ${2:# body...}\n }\n# Conditional if..else\nsnippet ife\n if {${1}} {\n ${2:# body...}\n } else {\n ${3:# else...}\n }\n# Conditional if..elsif..else\nsnippet ifee\n if {${1}} {\n ${2:# body...}\n } elseif {${3}} {\n ${4:# elsif...}\n } else {\n ${5:# else...}\n }\n# If catch then\nsnippet ifc\n if { [catch {${1:#do something...}} ${2:err}] } {\n ${3:# handle failure...}\n }\n# Catch\nsnippet catch\n catch {${1}} ${2:err} ${3:options}\n# While Loop\nsnippet wh\n while {${1}} {\n ${2:# body...}\n }\n# For Loop\nsnippet for\n for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} {\n ${4:# body...}\n }\n# Foreach Loop\nsnippet fore\n foreach ${1:x} {${2:#list}} {\n ${3:# body...}\n }\n# after ms script...\nsnippet af\n after ${1:ms} ${2:#do something}\n# after cancel id\nsnippet afc\n after cancel ${1:id or script}\n# after idle\nsnippet afi\n after idle ${1:script}\n# after info id\nsnippet afin\n after info ${1:id}\n# Expr\nsnippet exp\n expr {${1:#expression here}}\n# Switch\nsnippet sw\n switch ${1:var} {\n ${3:pattern 1} {\n ${4:#do something}\n }\n default {\n ${2:#do something}\n }\n }\n# Case\nsnippet ca\n ${1:pattern} {\n ${2:#do something}\n }${3}\n# Namespace eval\nsnippet ns\n namespace eval ${1:path} {${2:#script...}}\n# Namespace current\nsnippet nsc\n namespace current\n",t.scope="tcl"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/text.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/text",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="text"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/textile.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/textile",["require","exports","module"],function(e,t,n){t.snippetText='# Jekyll post header\nsnippet header\n ---\n title: ${1:title}\n layout: post\n date: ${2:date} ${3:hour:minute:second} -05:00\n ---\n\n# Image\nsnippet img\n !${1:url}(${2:title}):${3:link}!\n\n# Table\nsnippet |\n |${1}|${2}\n\n# Link\nsnippet link\n "${1:link text}":${2:url}\n\n# Acronym\nsnippet (\n (${1:Expand acronym})${2}\n\n# Footnote\nsnippet fn\n [${1:ref number}] ${3}\n\n fn$1. ${2:footnote}\n \n',t.scope="textile"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/toml.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/toml",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="toml"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/twig.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/twig",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="twig"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/typescript.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/typescript",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="typescript"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/vbscript.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/vbscript",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="vbscript"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/velocity.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/velocity",["require","exports","module"],function(e,t,n){t.snippetText='# macro\nsnippet #macro\n #macro ( ${1:macroName} ${2:\\$var1, [\\$var2, ...]} )\n ${3:## macro code}\n #end\n# foreach\nsnippet #foreach\n #foreach ( ${1:\\$item} in ${2:\\$collection} )\n ${3:## foreach code}\n #end\n# if\nsnippet #if\n #if ( ${1:true} )\n ${0}\n #end\n# if ... else\nsnippet #ife\n #if ( ${1:true} )\n ${2}\n #else\n ${0}\n #end\n#import\nsnippet #import\n #import ( "${1:path/to/velocity/format}" )\n# set\nsnippet #set\n #set ( $${1:var} = ${0} )\n',t.scope="velocity",t.includeScopes=["html","javascript","css"]}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/verilog.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/verilog",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="verilog"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/vhdl.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/vhdl",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="vhdl"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/xml.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/xml",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="xml"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/xquery.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/xquery",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="xquery"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ace/snippets/yaml.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/yaml",["require","exports","module"],function(e,t,n){t.snippetText="",t.scope="yaml"}) -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ebook.css: -------------------------------------------------------------------------------- 1 | .block-exercise { 2 | display: block !important; 3 | padding: 0px; 4 | margin: 20px 0px; 5 | border: 3px solid #2f8cde; 6 | background: #fff; 7 | color: #333; 8 | font-family: sans-serif; 9 | } 10 | 11 | .block-exercise .exercise-header { 12 | padding: 5px 15px; 13 | color: #fff; 14 | background: #2f8cde; 15 | font-size: 20px; 16 | } 17 | 18 | .block-exercise .exercise-inner { 19 | margin: 8px; 20 | } 21 | -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/ebook.html: -------------------------------------------------------------------------------- 1 |
2 |
Exercise
3 | 4 |
5 | <%= message %> 6 |
<%= codes.initial %>
7 |
8 |
-------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/exercises.css: -------------------------------------------------------------------------------- 1 | .book .book-body .page-wrapper .page-inner .exercise { 2 | display: block !important; 3 | padding: 0px; 4 | margin: 20px 0px; 5 | border: 3px solid #2f8cde; 6 | background: #fff; 7 | color: #333; 8 | font-family: sans-serif; 9 | } 10 | 11 | .page-inner .exercise .header { 12 | padding: 5px 15px; 13 | color: #fff; 14 | background: #2f8cde; 15 | font-size: 20px; 16 | } 17 | 18 | .page-inner .exercise .message { 19 | margin: 5px 15px; 20 | } 21 | 22 | .page-inner .exercise .editor { 23 | min-height: 50px; 24 | font-size: 14px; 25 | border-top: 1px solid #ddd; 26 | border-bottom: 1px solid #ddd; 27 | } 28 | 29 | .page-inner .exercise .alert { 30 | display: none; 31 | margin: 0px; 32 | margin-bottom: 10px; 33 | padding: 8px 15px; 34 | } 35 | 36 | .page-inner .exercise.return-error .alert-danger { 37 | display: block; 38 | } 39 | 40 | .page-inner .exercise.return-success .alert-success { 41 | display: block; 42 | } 43 | -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/jsrepl/langs/javascript/jsrepl_js.js: -------------------------------------------------------------------------------- 1 | (function(){self.JSREPLEngine=function(){function a(d,b,c,a,e,f){this.result=c;this.error=a;this.sandbox=e;this.inspect=this.sandbox.console.inspect;this.functionClass=this.sandbox.Function;this.sandbox.__eval=this.sandbox.eval;f()}a.prototype.Eval=function(d){var b;try{return b=this.sandbox.__eval(d),this.result(b===void 0?"":this.inspect(b))}catch(a){return this.error(a)}};a.prototype.RawEval=function(a){var b;try{return b=this.sandbox.__eval(a),this.result(b)}catch(c){return this.error(c)}};a.prototype.GetNextLineIndent= 2 | function(a){try{return new this.functionClass(a),false}catch(b){return/[\[\{\(]$/.test(a)?1:0}};return a}()}).call(this); 3 | -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/jsrepl/sandbox.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jsREPL Sandbox 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-exercises/website.html: -------------------------------------------------------------------------------- 1 |
2 |
Exercise
3 |
4 | Correct! 5 |
6 | 7 |
8 | False! 9 |
10 | 11 |
12 | <%= message %> 13 |
14 |
px"><%= codes.initial %>
15 | 16 | 17 | 18 | <% if (codes.context) { %> 19 | 20 | <% } %> 21 | 22 |
23 | Submit 24 | Solution 25 |
26 |
-------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-hide-published-with/plugin.js: -------------------------------------------------------------------------------- 1 | require(["gitbook"], function(gitbook) { 2 | $('.gitbook-link').hide(); 3 | gitbook.events.bind("page.change", function() { 4 | console.log("Hello custom plugin") 5 | $('.gitbook-link').hide(); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-hints/plugin-hints.css: -------------------------------------------------------------------------------- 1 | .hints-icon { 2 | display: table-cell; 3 | padding-right: 15px; 4 | padding-left: 5px; 5 | } 6 | 7 | .hints-container { 8 | display: table-cell; 9 | } 10 | -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-livereload/plugin.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var newEl = document.createElement('script'), 3 | firstScriptTag = document.getElementsByTagName('script')[0]; 4 | 5 | if (firstScriptTag) { 6 | newEl.async = 1; 7 | newEl.src = '//' + window.location.hostname + ':35729/livereload.js'; 8 | firstScriptTag.parentNode.insertBefore(newEl, firstScriptTag); 9 | } 10 | 11 | })(); 12 | -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-lunr/search-lunr.js: -------------------------------------------------------------------------------- 1 | require([ 2 | 'gitbook', 3 | 'jquery' 4 | ], function(gitbook, $) { 5 | // Define global search engine 6 | function LunrSearchEngine() { 7 | this.index = null; 8 | this.store = {}; 9 | this.name = 'LunrSearchEngine'; 10 | } 11 | 12 | // Initialize lunr by fetching the search index 13 | LunrSearchEngine.prototype.init = function() { 14 | var that = this; 15 | var d = $.Deferred(); 16 | 17 | $.getJSON(gitbook.state.basePath+'/search_index.json') 18 | .then(function(data) { 19 | // eslint-disable-next-line no-undef 20 | that.index = lunr.Index.load(data.index); 21 | that.store = data.store; 22 | d.resolve(); 23 | }); 24 | 25 | return d.promise(); 26 | }; 27 | 28 | // Search for a term and return results 29 | LunrSearchEngine.prototype.search = function(q, offset, length) { 30 | var that = this; 31 | var results = []; 32 | 33 | if (this.index) { 34 | results = $.map(this.index.search(q), function(result) { 35 | var doc = that.store[result.ref]; 36 | 37 | return { 38 | title: doc.title, 39 | url: doc.url, 40 | body: doc.summary || doc.body 41 | }; 42 | }); 43 | } 44 | 45 | return $.Deferred().resolve({ 46 | query: q, 47 | results: results.slice(0, length), 48 | count: results.length 49 | }).promise(); 50 | }; 51 | 52 | // Set gitbook research 53 | gitbook.events.bind('start', function(e, config) { 54 | var engine = gitbook.search.getEngine(); 55 | if (!engine) { 56 | gitbook.search.setEngine(LunrSearchEngine, config); 57 | } 58 | }); 59 | }); 60 | -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-search/search-engine.js: -------------------------------------------------------------------------------- 1 | require([ 2 | 'gitbook', 3 | 'jquery' 4 | ], function(gitbook, $) { 5 | // Global search objects 6 | var engine = null; 7 | var initialized = false; 8 | 9 | // Set a new search engine 10 | function setEngine(Engine, config) { 11 | initialized = false; 12 | engine = new Engine(config); 13 | 14 | init(config); 15 | } 16 | 17 | // Initialize search engine with config 18 | function init(config) { 19 | if (!engine) throw new Error('No engine set for research. Set an engine using gitbook.research.setEngine(Engine).'); 20 | 21 | return engine.init(config) 22 | .then(function() { 23 | initialized = true; 24 | gitbook.events.trigger('search.ready'); 25 | }); 26 | } 27 | 28 | // Launch search for query q 29 | function query(q, offset, length) { 30 | if (!initialized) throw new Error('Search has not been initialized'); 31 | return engine.search(q, offset, length); 32 | } 33 | 34 | // Get stats about search 35 | function getEngine() { 36 | return engine? engine.name : null; 37 | } 38 | 39 | function isInitialized() { 40 | return initialized; 41 | } 42 | 43 | // Initialize gitbook.search 44 | gitbook.search = { 45 | setEngine: setEngine, 46 | getEngine: getEngine, 47 | query: query, 48 | isInitialized: isInitialized 49 | }; 50 | }); -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-search/search.css: -------------------------------------------------------------------------------- 1 | /* 2 | This CSS only styled the search results section, not the search input 3 | It defines the basic interraction to hide content when displaying results, etc 4 | */ 5 | #book-search-results .search-results { 6 | display: none; 7 | } 8 | #book-search-results .search-results ul.search-results-list { 9 | list-style-type: none; 10 | padding-left: 0; 11 | } 12 | #book-search-results .search-results ul.search-results-list li { 13 | margin-bottom: 1.5rem; 14 | padding-bottom: 0.5rem; 15 | /* Highlight results */ 16 | } 17 | #book-search-results .search-results ul.search-results-list li p em { 18 | background-color: rgba(255, 220, 0, 0.4); 19 | font-style: normal; 20 | } 21 | #book-search-results .search-results .no-results { 22 | display: none; 23 | } 24 | #book-search-results.open .search-results { 25 | display: block; 26 | } 27 | #book-search-results.open .search-noresults { 28 | display: none; 29 | } 30 | #book-search-results.no-results .search-results .has-results { 31 | display: none; 32 | } 33 | #book-search-results.no-results .search-results .no-results { 34 | display: block; 35 | } 36 | -------------------------------------------------------------------------------- /_book/gitbook/gitbook-plugin-sidebar-ad/sidebar-ad.css: -------------------------------------------------------------------------------- 1 | .book-summary ul.summary { 2 | overflow-y: scroll; 3 | height: calc(100% - 196px); 4 | position: absolute; 5 | width: 300px; 6 | } 7 | 8 | .sidebar-addition { 9 | position:fixed; 10 | height: 150px; 11 | width: 300px; 12 | left: 0; 13 | bottom: 0; 14 | background: #fafafa; 15 | border-top: 1px solid rgba(0,0,0,.07); 16 | border-right: 1px solid rgba(0,0,0,.07); 17 | text-align: center; 18 | display: none; 19 | } 20 | 21 | .sidebar-addition img { 22 | height: 90%; 23 | margin: 2.5%; 24 | float: left; 25 | } 26 | 27 | .sidebar-addition p { 28 | line-height: 150%; 29 | padding: 10px; 30 | margin: 0 0 10px 0; 31 | } 32 | 33 | .sidebar-addition .btn { 34 | background: rgba(0,0,0,.07); 35 | color: rgba(0,0,0,0.4); 36 | padding: 5px 10px; 37 | border-radius: 4px; 38 | margin-top: 5px; 39 | } 40 | 41 | .with-summary .sidebar-addition { 42 | display: block; 43 | } 44 | -------------------------------------------------------------------------------- /_book/gitbook/images/apple-touch-icon-precomposed-152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/gitbook/images/apple-touch-icon-precomposed-152.png -------------------------------------------------------------------------------- /_book/gitbook/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/gitbook/images/favicon.ico -------------------------------------------------------------------------------- /_book/js.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/js.png -------------------------------------------------------------------------------- /_book/ne/error-handling/README.md: -------------------------------------------------------------------------------- 1 | # Error Handling 2 | 3 | -------------------------------------------------------------------------------- /_book/ne/exercises/README.md: -------------------------------------------------------------------------------- 1 | # Exercises 2 | 3 | -------------------------------------------------------------------------------- /_book/ne/miscellaneous/README.md: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | 3 | -------------------------------------------------------------------------------- /_book/ne/promise-async-await/README.md: -------------------------------------------------------------------------------- 1 | # Promise, async/await (प्रतिज्ञा, असिंक/प्रतीक्षा) 2 | 3 | -------------------------------------------------------------------------------- /_book/ne/template-literals/linked-list/translate.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/ne/template-literals/linked-list/translate.json -------------------------------------------------------------------------------- /_book/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "javascript_tutorial", 3 | "version": "1.0.0", 4 | "description": "Learn JavaScript", 5 | "main": "index.js", 6 | "devDependencies": { 7 | "gitbook-plugin-edit-link": "^2.0.2", 8 | "gitbook-plugin-chapter-fold": "^0.0.4", 9 | "gitbook-plugin-exercises": "^3.0.0", 10 | "gitbook-plugin-favicon-custom": "^1.0.0", 11 | "gitbook-plugin-hide-published-with": "0.0.1", 12 | "gitbook-plugin-hints": "^1.0.2", 13 | "gitbook-plugin-intopic-toc": "^1.0.6", 14 | "gitbook-plugin-sharing": "https://github.com/sumn2u/plugin-sharing.git", 15 | "gitbook-plugin-sidebar-ad": "0.0.4", 16 | "gitbook-plugin-sitemap": "^1.2.0", 17 | "gitbook-plugin-theme-creative": "^1.0.6", 18 | "honkit": "^4.0.4", 19 | "honkit-plugin-i18nsettings": "^1.0.0" 20 | }, 21 | "scripts": { 22 | "start": "honkit serve", 23 | "build": "exit 0" 24 | }, 25 | "keywords": [], 26 | "author": "Suman Kunwar", 27 | "license": "CC-BY-SA-4.0" 28 | } 29 | -------------------------------------------------------------------------------- /_book/star_us.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/_book/star_us.gif -------------------------------------------------------------------------------- /_layouts/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {% block title %}{{ config.title|d("HonKit", true) }}{% endblock %} 6 | 7 | 8 | 9 | {% if config.author %}{% endif %} 10 | {% if config.isbn %}{% endif %} 11 | {% block style %} 12 | {% for resource in plugins.resources.css %} 13 | {% if resource.url %} 14 | 15 | {% else %} 16 | 17 | {% endif %} 18 | {% endfor %} 19 | {% endblock %} 20 | {% block head %}{% endblock %} 21 | 22 | 23 | {% block body %}{% endblock %} 24 | {% block javascript %}{% endblock %} 25 | 26 | -------------------------------------------------------------------------------- /_layouts/website/header.html: -------------------------------------------------------------------------------- 1 | {% block book_header %} 2 | 13 | {% endblock %} -------------------------------------------------------------------------------- /_layouts/website/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | 3 | {% block head %} 4 | {{ super() }} 5 | 6 | 7 | 8 | 9 | 10 | 11 | {% endblock %} 12 | 13 | {% block style %} 14 | {### Include theme css before plugins css ###} 15 | 16 | 17 | {{ super() }} 18 | 19 | {### Custom stylesheets for the book ###} 20 | 21 | {% for type, style in config.styles %} 22 | {% if fileExists(style) and type == "website" %} 23 | 24 | {% endif %} 25 | {% endfor %} 26 | {% endblock %} 27 | 28 | {% block body %}{% endblock %} -------------------------------------------------------------------------------- /book.epub: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/book.epub -------------------------------------------------------------------------------- /book.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/book.pdf -------------------------------------------------------------------------------- /cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/cover.jpg -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | book: 4 | tty: true 5 | restart: always 6 | build: 7 | context: . 8 | dockerfile: ./Dockerfile 9 | ports: 10 | - "4000:4000" 11 | - "35729:35729" 12 | volumes: 13 | - .:/usr/src/app 14 | - modules:/usr/src/app/node_modules 15 | command: npm start 16 | working_dir: /usr/src/app 17 | volumes: 18 | modules: 19 | driver: local -------------------------------------------------------------------------------- /en/arrays/for-each.md: -------------------------------------------------------------------------------- 1 | # For Each 2 | 3 | The `forEach` method executes a provided function once for each array element. Here's the syntax for using `forEach`: 4 | 5 | ```javascript 6 | array.forEach(function(element, index, array) { 7 | // element: current element being processed in the array 8 | // index: index of the current element being processed in the array 9 | // array: the array forEach was called upon 10 | }); 11 | ``` 12 | 13 | \ 14 | For example, let's say you have an array of numbers and you want to print the double of each number to the console. You could do this using `forEach` like this: 15 | 16 | ```typescript 17 | let numbers = [1, 2, 3, 4, 5]; 18 | numbers.forEach(function(number) { 19 | console.log(number * 2); 20 | }); 21 | ``` 22 | 23 | You can also use the arrow function syntax to define the function passed to `forEach`: 24 | 25 | ```typescript 26 | numbers.forEach((number) => { 27 | console.log(number * 2); 28 | }); 29 | ``` 30 | 31 | or 32 | 33 | ```typescript 34 | numbers.forEach(number => console.log(number * 2)); 35 | ``` 36 | 37 | `forEach` does not modify the original array. It simply iterates over the elements of the array and executes the provided function for each element. 38 | 39 | {% hint style="warning" %} 40 | The `forEach()` method is not executed for the empty statment. 41 | {% endhint %} 42 | -------------------------------------------------------------------------------- /en/arrays/indices.md: -------------------------------------------------------------------------------- 1 | # Indices 2 | 3 | So you have your array of data elements, but what if you want to access a specific element? That is where indices come in. An **index** refers to a spot in the array. indices logically progress one by one, but it should be noted that the first index in an array is 0, as it is in most languages. Brackets `[]` are used to signify you are referring to an index of an array. 4 | 5 | ```javascript 6 | // This is an array of strings 7 | let fruits = ["apple", "banana", "pineapple", "strawberry"]; 8 | 9 | // We set the variable banana to the value of the second element of 10 | // the fruits array. Remember that indices start at 0, so 1 is the 11 | // second element. Result: banana = "banana" 12 | let banana = fruits[1]; 13 | ``` 14 | 15 | You can also use an array index to set the value of an element in an array: 16 | 17 | ```javascript 18 | let array = ['a', 'b', 'c', 'd', 'e']; 19 | // indices: 0 1 2 3 4 20 | array[4] = 'f'; 21 | console.log(array); // Result: ['a', 'b', 'c', 'd', 'f'] 22 | ``` 23 | 24 | Note that if you try to access or set an element using an index that is outside the bounds of the array (i.e., an index that is less than 0 or greater than or equal to the length of the array), you will get an `undefined` value. 25 | 26 | ```javascript 27 | console.log(array[5]); // Output: undefined 28 | array[5] = 'g'; 29 | console.log(array); // Result: ['a', 'b', 'c', 'd', 'f', undefined, 'g'] 30 | ``` 31 | -------------------------------------------------------------------------------- /en/arrays/join.md: -------------------------------------------------------------------------------- 1 | # Join 2 | 3 | The `join` method, makes an array turn into a string and joins it all together. It does not change the original array. Here's the syntax for using `join`: 4 | 5 | ```c 6 | array.join([separator]); 7 | ``` 8 | 9 | The `separator` argument is optional and specifies the character to be used to separate the elements in the resulting string. If omitted, the array elements are separated with a comma (`,`). 10 | 11 | For example: 12 | 13 | ```javascript 14 | let array = ["one", "two", "three", "four"]; 15 | 16 | console.log(array.join(" ")); 17 | 18 | // Result: one two three four 19 | ``` 20 | 21 | {% hint style="warning" %} 22 | Any separator can be specified but the default one is a comma `(,)`. 23 | {% endhint %} 24 | 25 | In the above example, a space is used as a separator. You can also use `join` to convert an array-like object (such as an arguments object or a NodeList object) to a string by first converting it to an array using the `Array.prototype.slice()` method: 26 | 27 | ```javascript 28 | function printArguments() { 29 | console.log(Array.prototype.slice.call(arguments).join(', ')); 30 | } 31 | 32 | printArguments('a', 'b', 'c'); // Result: "a, b, c" 33 | ``` 34 | -------------------------------------------------------------------------------- /en/arrays/length.md: -------------------------------------------------------------------------------- 1 | # Length 2 | 3 | Arrays have a property called `length`, and it's pretty much exactly as it sounds, it's the length of the array. 4 | 5 | ```javascript 6 | let array = [1, 2, 3]; 7 | 8 | let l = array.length; 9 | 10 | // Result: l = 3 11 | ``` 12 | 13 | The length property also sets the number of elements in an array. For example. 14 | 15 | ```javascript 16 | let fruits = ["Banana", "Orange", "Apple", "Mango"]; 17 | fruits.length = 2; 18 | 19 | console.log(fruits); 20 | // Result: ['Banana', 'Orange'] 21 | ``` 22 | 23 | You can also use the `length` property to get the last element of an array by using it as an index. For example: 24 | 25 | ```c 26 | console.log(fruits[fruits.length - 1]); // Result: Orange 27 | ``` 28 | 29 | You can also use the `length` property to add elements to the end of an array. For example: 30 | 31 | ```c 32 | fruits[fruits.length] = "Pineapple"; 33 | console.log(fruits); // Result: ['Banana', 'Orange', 'Pineapple'] 34 | ``` 35 | 36 | {% hint style="info" %} 37 | The `length` property is automatically updated when elements are added or removed from the array. 38 | {% endhint %} 39 | 40 | It's also worth noting that the `length` property is not a method, so you don't need to use parentheses when accessing it. It's simply a property of the array object that you can access like any other object property. 41 | -------------------------------------------------------------------------------- /en/arrays/map.md: -------------------------------------------------------------------------------- 1 | # Map 2 | 3 | The `Array.prototype.map()` method iterates over an array and modifies its elements using a callback function. The callback function will then be applied to each element of the array. 4 | 5 | Here's the syntax for using `map`: 6 | 7 | ```javascript 8 | let newArray = oldArray.map(function(element, index, array) { 9 | // element: current element being processed in the array 10 | // index: index of the current element being processed in the array 11 | // array: the array map was called upon 12 | // Return element to be added to newArray 13 | }); 14 | ``` 15 | 16 | For example, let's say you have an array of numbers and you want to create a new array that doubles the values of the numbers in the original array. You could do this using `map` like this: 17 | 18 | ```javascript 19 | const numbers = [2, 4, 6, 8]; 20 | 21 | const doubledNumbers = numbers.map(number => number * 2); 22 | 23 | console.log(doubledNumbers); 24 | 25 | // Result: [4, 8, 12, 16] 26 | ``` 27 | 28 | You can also use the arrow function syntax to define the function passed to `map`: 29 | 30 |
let doubledNumbers = numbers.map((number) => {
31 |   return number * 2;
32 | });
33 | 
34 | 35 | or 36 | 37 | ```typescript 38 | let doubledNumbers = numbers.map(number => number * 2); 39 | ``` 40 | 41 | {% hint style="info" %} 42 | The `map()` method doesn't execute function for empty elements and doesn't change the original array. 43 | {% endhint %} 44 | -------------------------------------------------------------------------------- /en/arrays/pop.md: -------------------------------------------------------------------------------- 1 | # Pop 2 | 3 | The `pop` method removes the last element from an array and returns that element. This method changes the length of the array. 4 | 5 | Here's the syntax for using `pop`: 6 | 7 | ```c 8 | array.pop(); 9 | ``` 10 | 11 | For example: 12 | 13 | ```javascript 14 | let arr = ["one", "two", "three", "four", "five"]; 15 | arr.pop(); 16 | 17 | console.log(arr); 18 | 19 | // Result: ['one', 'two', 'three', 'four'] 20 | ``` 21 | 22 | You can also use the `pop` method in conjunction with a loop to remove all elements from an array. Here's an example of how you might do this: 23 | 24 | ```c 25 | while (array.length > 0) { 26 | array.pop(); 27 | } 28 | 29 | console.log(array); // Result: [] 30 | ``` 31 | 32 | {% hint style="warning" %} 33 | The `pop` method only works on arrays, and not on other objects that are similar to arrays such as arguments objects or NodeList objects. If you need to pop elements from one of these types of objects, you will need to convert it to an array first using the `Array.prototype.slice()` method.\ 34 | 35 | {% endhint %} 36 | -------------------------------------------------------------------------------- /en/arrays/push.md: -------------------------------------------------------------------------------- 1 | # Push 2 | 3 | One can push certain items to an array making the last index the newly added item. It changes the length of an array and returns a new length. 4 | 5 | Here's the syntax for using `push`: 6 | 7 | ```c 8 | array.push(element1[, ...[, elementN]]); 9 | ``` 10 | 11 | The `element1, ..., elementN` arguments represent the elements to be added to the end of the array. 12 | 13 | For example: 14 | 15 | ```javascript 16 | let array = [1, 2, 3]; 17 | array.push(4); 18 | 19 | console.log(array); 20 | 21 | // Result: array = [1, 2, 3, 4] 22 | ``` 23 | 24 | You can also use `push` to add elements to the end of an array-like object (such as an arguments object or a NodeList object) by first converting it to an array using the `Array.prototype.slice()` method: 25 | 26 | ```javascript 27 | function printArguments() { 28 | let args = Array.prototype.slice.call(arguments); 29 | args.push('d', 'e', 'f'); 30 | console.log(args); 31 | } 32 | 33 | printArguments('a', 'b', 'c'); // Result: ["a", "b", "c", "d", "e", "f"] 34 | ``` 35 | 36 | Note that the `push` method modifies the original array. It does not create a new array. 37 | -------------------------------------------------------------------------------- /en/arrays/shift.md: -------------------------------------------------------------------------------- 1 | # Shift 2 | 3 | `shift` deletes the first index of that array and moves all indexes to the left. It changes the original array. Here's the syntax for using `shift`: 4 | 5 | ```c 6 | array.shift(); 7 | ``` 8 | 9 | For example: 10 | 11 | ```javascript 12 | let array = [1, 2, 3]; 13 | array.shift(); 14 | 15 | // Result: array = [2,3] 16 | ``` 17 | 18 | You can also use the `shift` method in conjunction with a loop to remove all elements from an array. Here's an example of how you might do this: 19 | 20 | ```c 21 | while (array.length > 0) { 22 | array.shift(); 23 | } 24 | 25 | console.log(array); // Result: [] 26 | ``` 27 | 28 | {% hint style="warning" %} 29 | The `shift` method only works on arrays, and not on other objects that are similar to arrays such as arguments objects or NodeList objects. If you need to shift elements from one of these types of objects, you will need to convert it to an array first using the `Array.prototype.slice()` method. 30 | {% endhint %} 31 | -------------------------------------------------------------------------------- /en/arrays/sort.md: -------------------------------------------------------------------------------- 1 | # Sort 2 | 3 | The `sort` method sorts the items of an array in a specific order (ascending or descending). 4 | 5 | Here's the syntax for using `sort`: 6 | 7 | ```c 8 | array.sort([compareFunction]); 9 | ``` 10 | 11 | The `compareFunction` argument is optional and specifies a function that defines the sort order. If omitted, the elements are sorted in ascending order according to their string representation. 12 | 13 | For example: 14 | 15 | ```javascript 16 | let city = ["California", "Barcelona", "Paris", "Kathmandu"]; 17 | let sortedCity = city.sort(); 18 | 19 | console.log(sortedCity); 20 | 21 | // Result: ['Barcelona', 'California', 'Kathmandu', 'Paris'] 22 | 23 | ``` 24 | 25 | {% hint style="info" %} 26 | Numbers can be sorted incorrectly when they are sorted. For example, "35" is bigger than "100", because "3" is bigger than "1". 27 | {% endhint %} 28 | 29 | To fix the sorting issue in numbers, compare functions are used. Compare functions defines sort orders and return a **negative**, **zero**, or **positive** value based on arguments, like this: 30 | 31 | * A negative value if `a` should be sorted before `b` 32 | * A positive value if `a` should be sorted after `b` 33 | * `0` if `a` and `b` are equal and their order doesn't matter 34 | 35 | ```javascript 36 | const points = [40, 100, 1, 5, 25, 10]; 37 | points.sort((a, b) => {return a-b}); 38 | 39 | // Result: [1, 5, 10, 25, 40, 100] 40 | ``` 41 | 42 | {% hint style="warning" %} 43 | The `sort()` method overrides the original array. 44 | {% endhint %} 45 | -------------------------------------------------------------------------------- /en/arrays/spread.md: -------------------------------------------------------------------------------- 1 | # Spread 2 | 3 | An array or object can be quickly copied into another array or object by using the Spread Operator `(...)`. It allows an iterable such as an array to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected. 4 | 5 | Here are some examples of it: 6 | 7 | ```javascript 8 | let arr = [1, 2, 3, 4, 5]; 9 | 10 | console.log(...arr); 11 | // Result: 1 2 3 4 5 12 | 13 | let arr1; 14 | arr1 = [...arr]; //copies the arr into arr1 15 | 16 | console.log(arr1); //Result: [1, 2, 3, 4, 5] 17 | 18 | arr1 = [6,7]; 19 | arr = [...arr,...arr1]; 20 | 21 | console.log(arr); //Result: [1, 2, 3, 4, 5, 6, 7] 22 | 23 | ``` 24 | 25 | {% hint style="warning" %} 26 | The spread operator only works in modern browsers that support the feature. If you need to support older browsers, you will need to use a transpiler like Babel to convert the spread operator syntax to equivalent ES5 code. 27 | {% endhint %} 28 | -------------------------------------------------------------------------------- /en/arrays/unshift.md: -------------------------------------------------------------------------------- 1 | # Unshift 2 | 3 | The `unshift` method adds new elements sequentially to the start, or front of the array. It modifies the original array and returns the new length of the array. For example. 4 | 5 | ```javascript 6 | let array = [0, 5, 10]; 7 | array.unshift(-5); // 4 8 | 9 | // RESULT: array = [-5 , 0, 5, 10]; 10 | ``` 11 | 12 | {% hint style="warning" %} 13 | The `unshift()` method overwrites the original array. 14 | {% endhint %} 15 | 16 | The `unshift` method takes one or more arguments, which represent the elements to be added to the beginning of the array. It adds the elements in the order they are provided, so the first element will be the first element of the array. 17 | 18 | Here is an example of using `unshift` to add multiple elements to an array: 19 | 20 | ```javascript 21 | const numbers = [1, 2, 3]; 22 | const newLength = numbers.unshift(-1, 0); 23 | console.log(numbers); // [-1, 0, 1, 2, 3] 24 | console.log(newLength); // 5 25 | ``` 26 | -------------------------------------------------------------------------------- /en/basics/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: editorial 3 | --- 4 | 5 | # Basics 6 | 7 | In this first chapter, we'll learn the basics of programming and the Javascript language. 8 | 9 | Programming means writing code. A book is made up of chapters, paragraphs, sentences, phrases, words, and finally punctuation and letters, likewise a program can be broken down into smaller and smaller components. For now, the most important is a statement. A statement is analogous to a sentence in a book. On its own, it has structure and purpose, but without the context of the other statements around it, it isn't that meaningful. 10 | 11 | A statement is more casually (and commonly) known as a _line of code_. That's because statements tend to be written on individual lines. As such, programs are read from top to bottom, left to right. You might be wondering what code (also called source code) is. That happens to be a broad term which can refer to the whole of the program or the smallest part. Therefore, a line of code is simply a line of your program. 12 | 13 | Here is a simple example: 14 | 15 | ```javascript 16 | let hello = "Hello"; 17 | let world = "World"; 18 | 19 | // Message equals "Hello World" 20 | let message = hello + " " + world; 21 | ``` 22 | 23 | This code can be executed by another program called an _interpreter_ that will read the code, and execute all the statements in the right order. 24 | -------------------------------------------------------------------------------- /en/basics/comments.md: -------------------------------------------------------------------------------- 1 | # Comments 2 | 3 | Comments are statements that will not be executed by the interpreter, comments are used to mark annotations for other programmers or small descriptions of what code does, thus making it easier for others to understand what your code does. 4 | 5 | In JavaScript, comments can be written in 2 different ways: 6 | 7 | * _Single-line comments_: It starts with two forward slashes (`//`) and continue until the end of the line. Anything following the slashes is ignored by the JavaScript interpreter. For example : 8 | 9 | ```javascript 10 | // This is a comment, it will be ignored by the interpreter 11 | let a = "this is a variable defined in a statement"; 12 | ``` 13 | 14 | * Multi-line comments: It starts with a forward slash and an asterisk (`/*`) and end with an asterisk and a forward slash (`*/`). Anything between the opening and closing markers is ignored by the JavaScript interpreter. For example: 15 | 16 | ```javascript 17 | /* 18 | This is a multi-line comment, 19 | it will be ignored by the interpreter 20 | */ 21 | let a = "this is a variable defined in a statement"; 22 | ``` 23 | -------------------------------------------------------------------------------- /en/browser-object-model-bom/README.md: -------------------------------------------------------------------------------- 1 | # Browser Object Model (BOM) 2 | 3 | The browser object model lets us interact with the browser window. `window` object represents the browser's window and is supported by all browsers. 4 | 5 | Object `window` is the default object for a browser, so we can specify `window` or call directly all the functions. 6 | 7 | ```javascript 8 | window.alert("Welcome to Learn JavaScript"); 9 | 10 | alert("Welcome to Learn JavaScript") 11 | ``` 12 | 13 | In a similar fashion, we can call other properties underneath the window object such as history, screen, navigator, location, and so on. 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /en/browser-object-model-bom/cookies.md: -------------------------------------------------------------------------------- 1 | # Cookies 2 | 3 | Cookies are pieces of information that are store on a computer and can be accessed by the browser. 4 | 5 | Communication between a web browser and the server is stateless meaning that it treats each request independently. There are cases where we need to store user information and make that information available to the browser. With cookies, information can be fetched from the computer whenever it is required. 6 | 7 | Cookies are saved in name-value pair 8 | 9 | ```javascript 10 | book = Learn Javascript 11 | ``` 12 | 13 | `document.cookie` property is used to create, read and delete cookies.Creating cookie is pretty easy you need to provide the name and value 14 | 15 | ```javascript 16 | document.cookie = "book=Learn Javacript"; 17 | ``` 18 | 19 | By default, a cookie gets deleted when the browser is closed. To make it persistent, we need to specify the expiry date(in UTC time). 20 | 21 | ```javascript 22 | document.cookie = "book=Learn Javacript; expires=Fri, 08 Jan 2022 12:00:00 UTC"; 23 | ``` 24 | 25 | We can add a parameter to tell which path the cookie belongs to. By default, the cookie belongs to the current page. 26 | 27 | ```javascript 28 | document.cookie = "book=Learn Javacript; expires=Fri, 08 Jan 2022 12:00:00 UTC; path=/"; 29 | ``` 30 | 31 | Here is a simple example of a cookie. 32 | 33 | ```javascript 34 | let cookies = document.cookie; 35 | // a simple way to reterive all cookie. 36 | 37 | document.cookie = "book=Learn Javacript; expires=Fri, 08 Jan 2022 12:00:00 UTC; path=/"; 38 | // setting up a cookie 39 | ``` 40 | -------------------------------------------------------------------------------- /en/browser-object-model-bom/history.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: History object manages the browser's history stack. 3 | --- 4 | 5 | # History 6 | 7 | When we open a web browser and surf a web page it creates a new entry in the history stack. As we keep navigating to different pages new entries get pushed into the stack. 8 | 9 | To access the history object we can use 10 | 11 | ```javascript 12 | window.history 13 | // or 14 | history 15 | ``` 16 | 17 | To navigate between the different history stack we can use `go()` , `foward()` and `back()`methods of **history** object. 18 | 19 | 1. **go\(\)**: It is used to navigate the specific URL of the history stack. 20 | 21 | ```javascript 22 | history.go(-1); // moves page backward 23 | history.go(0); // refreshes the current page 24 | history.go(); // refreshes the current page 25 | history.go(1) // moves page forward 26 | ``` 27 | 28 | > _**Note:**_ the current page position in history stack is **0**. 29 | 30 | 2. **back\(\)** : To navigate page backward we use `back()` method. 31 | 32 | ```javascript 33 | history.back(); 34 | ``` 35 | 36 | 3. **forward\(\)**: It loads the next list in the browser history. It is similar to clicking the forward button in the browser. 37 | 38 | ```javascript 39 | history.forward(); 40 | ``` 41 | 42 | -------------------------------------------------------------------------------- /en/browser-object-model-bom/location.md: -------------------------------------------------------------------------------- 1 | # Location 2 | 3 | `Location` object is used to retrieve the current location (URL) of the document and provides different methods to manipulate document location. One can access the current location by 4 | 5 | ```javascript 6 | window.location 7 | //or 8 | document.location 9 | //or 10 | location 11 | ``` 12 | 13 | > _**Note**_: `window.location` and `document.location` references the same location object. 14 | 15 | Let's take an example of the following URL and explore the different properties of `location` 16 | 17 | [`http://localhost:3000/js/index.html?type=listing&page=2#title`](http://localhost:8080/js/index.html?type=listing\&page=2#title) 18 | 19 | ```javascript 20 | location.href //prints current document URL 21 | location.protocol //prints protocol like http: or https: 22 | location.host //prints hostname with port like localhost or localhost:3000 23 | location.hostname //prints hostname like localhost or www.example.com 24 | location.port //prints port number like 3000 25 | location.pathname //prints pathname like /js/index.html 26 | location.search //prints query string like ?type=listing&page=2 27 | location.hash //prints fragment identifier like #title 28 | ``` 29 | -------------------------------------------------------------------------------- /en/browser-object-model-bom/navigator.md: -------------------------------------------------------------------------------- 1 | # Navigator 2 | 3 | `window.navigator` or `navigator` is a **read-only** property and contains different methods and functions related to the browser. 4 | 5 | Let's look at a few examples of navigation. 6 | 7 | 1. **navigator.appName**: It gives the name of the browser application 8 | 9 | ```javascript 10 | navigator.appName; 11 | // "Netscape" 12 | ``` 13 | 14 | > _**Note:**_ "Netscape" is the application name for IE11, Chrome, Firefox, and Safari. 15 | 2. **navigator.cookieEnabled**: Returns a boolean value based on the cookie value in the browser. 16 | 17 | ```javascript 18 | navigator.cookieEnabled; 19 | //true 20 | ``` 21 | 3. **navigator.platform**: Provides information about the browser operating system. 22 | 23 | ```javascript 24 | navigator.patform; 25 | "MacIntel" 26 | ``` 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /en/browser-object-model-bom/popup.md: -------------------------------------------------------------------------------- 1 | # Popup 2 | 3 | Popups are an additional way to show information, take user confirmation, or take user input from additional documents. A popup can navigate to a new URL and send information to the opener window. **Alert box**, **Confirmation box**, and **Prompt box** are the global functions where we can show the popup information. 4 | 5 | 1. **alert()**: It displays information to the user and has an "**OK**" button to proceed. 6 | 7 | ```javascript 8 | alert("Alert message example"); 9 | ``` 10 | 2. **confirm()**: Use as a dialog box to confirm or accept something. It has "**Ok**" and "**Cancel**" to proceed. If the user clicks "**Ok**" then it returns `true`, if click "**Cancel**" it returns `false`. 11 | 12 | ```javascript 13 | let txt; 14 | if (confirm("Press a button!")) { 15 | txt = "You pressed OK!"; 16 | } else { 17 | txt = "You pressed Cancel!"; 18 | } 19 | ``` 20 | 3. **prompt()**: Takes user input value with "**Ok"** and "**Cancel"** buttons. It returns `null` if the user does not provide any input value. 21 | 22 | ```javascript 23 | //syntax 24 | //window.prompt("sometext","defaultText"); 25 | 26 | let person = prompt("Please enter your name", "Harry Potter"); 27 | 28 | if (person == null || person == "") { 29 | txt = "User cancelled the prompt."; 30 | } else { 31 | txt = "Hello " + person + "! How are you today?"; 32 | } 33 | ``` 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /en/browser-object-model-bom/screen.md: -------------------------------------------------------------------------------- 1 | # Screen 2 | 3 | The `screen` object contains the information about the screen on which the current window is being rendered. To access `screen` object we can use the `screen` property of `window` object. 4 | 5 | ```javascript 6 | window.screen 7 | //or 8 | screen 9 | ``` 10 | 11 | The `window.screen` object has different properties, some of them are listed here: 12 | 13 | | Property | Description | 14 | | :--- | :--- | 15 | | `height` | Represents the pixel height of the screen. | 16 | | `left` | Represents the pixel distance of the current screen’s left side. | 17 | | `pixelDepth` | A read-only property that returns the bit depth of the screen. | 18 | | `top` | Represents the pixel distance of the current screen’s top. | 19 | | `width` | Represents the pixel width of the screen. | 20 | | `orientation` | Returns the screen orientation as specified in the Screen Orientation API | 21 | | `availTop` | A read-only property that returns the first pixel from the top that is not taken up by system elements. | 22 | | `availWidth` | A read-only property that returns the pixel width of the screen excluding system elements. | 23 | | `colorDepth` | A read-only property that returns the number of bits used to represent colors. | 24 | | `height` | Represents the pixel height of the screen. | 25 | | `left` | Represents the pixel distance of the current screen’s left side. | 26 | | `pixelDepth` | A read-only that returns the bit depth of the screen. | 27 | | `top` | Represents the pixel distance of the current screen’s top. | 28 | | `width` | Represents the pixel width of the screen. | 29 | | `orientation` | Returns the screen orientation as specified in the Screen Orientation API | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /en/browser-object-model-bom/window.md: -------------------------------------------------------------------------------- 1 | # Window 2 | 3 | The `window` object represents the browser window and is supported by the browsers. Global variables, objects, and functions are also part of the window object. 4 | 5 | Global **variables** are **properties** and **functions** are **methods** of the window object. 6 | 7 | Let's take an example of the screen properties. It is used to determine the size of the browser window and is measured in pixels. 8 | 9 | * `window.innerHeight` - the inner height of the browser window 10 | * `window.innerWidth` - the inner width of the browser window 11 | 12 | > _**Note**_: `window.document` is same as `document.location` as the document object model\(DOM\) is part of window object. 13 | 14 | Few examples of the window methods 15 | 16 | * `window.open()` - open a new window 17 | * `window.close()` - close the current window 18 | * `window.moveTo()` - move the current window 19 | * `window.resizeTo()` - resize the current window 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /en/classes/README.md: -------------------------------------------------------------------------------- 1 | # Classes 2 | 3 | Classes are templates for creating an object. It encapsulates data with code to work on with data. The keyword `class` is used to create a class. And a specific method called `constructor` is used for creating and initializing an object created with a `class`. An example of car class is shown below. 4 | 5 | ```javascript 6 | class Car { 7 | constructor(name, year) { 8 | this.name = name; 9 | this.year = year; 10 | } 11 | age() { 12 | let date = new Date(); 13 | return date.getFullYear() - this.year; 14 | } 15 | } 16 | 17 | let myCar = new Car("Toyota", 2021); 18 | console.log(myCar.age()) // 1 19 | ``` 20 | 21 | {% hint style="info" %} 22 | Class must be defined before its usage. 23 | {% endhint %} 24 | 25 | In the class body, methods or constructors are defined and executed in `strict mode`. Syntax not adhering to the strict mode results in error. 26 | -------------------------------------------------------------------------------- /en/classes/access-modifiers.md: -------------------------------------------------------------------------------- 1 | # Access Modifiers 2 | 3 | `public`, `private`, and `protected` are the three access modifiers used in class to control its access from the outside. By default, all members (properties, fields, methods, or functions) are publicly accessible from outside the class. 4 | 5 | ```javascript 6 | class Car { 7 | constructor(name) { 8 | this.name = name; 9 | } 10 | static hello(x) { 11 | return "Hello " + x.name; 12 | } 13 | } 14 | let myCar = new Car("Toyota"); 15 | console.log(Car.hello(myCar)); // Hello Toyota 16 | ``` 17 | 18 | `private` members can access only internally within the class and cannot be accessible from outside. Private should start with `#`. 19 | 20 | ```javascript 21 | class Car { 22 | constructor(name) { 23 | this.name = name; 24 | } 25 | static hello(x) { 26 | return "Hello " + x.name; 27 | } 28 | #present(carname) { 29 | return 'I have a ' + this.carname; 30 | } 31 | } 32 | let myCar = new Car("Toyota"); 33 | console.log(myCar.#present("Camry")); // Error 34 | console.log(Car.hello(myCar)); // Hello Toyota 35 | ``` 36 | 37 | `protected` fields are accessible only from inside the class and those extending it. These are useful for the internal interface as the inheriting class also gains access to the parent class. Protected fields with `_` . 38 | 39 | ```javascript 40 | class Car { 41 | constructor(brand) { 42 | this.carname = brand; 43 | } 44 | _present() { 45 | return 'I have a ' + this.carname; 46 | } 47 | } 48 | 49 | class Model extends Car { 50 | constructor(brand, mod) { 51 | super(brand); 52 | this.model = mod; 53 | } 54 | show() { 55 | return this._present() + ', it is a ' + this.model; 56 | } 57 | } 58 | 59 | let myCar = new Model("Toyota", "Camry"); 60 | console.log(myCar.show()) // I have a Toyota, it is a Camry 61 | ``` 62 | -------------------------------------------------------------------------------- /en/classes/inheritance.md: -------------------------------------------------------------------------------- 1 | # Inheritance 2 | 3 | The inheritance is useful for code reusability purposes as it extends existing properties and methods of a class. The `extends` keyword is used to create a class inheritance. 4 | 5 | ```javascript 6 | class Car { 7 | constructor(brand) { 8 | this.carname = brand; 9 | } 10 | present() { 11 | return 'I have a ' + this.carname; 12 | } 13 | } 14 | 15 | class Model extends Car { 16 | constructor(brand, mod) { 17 | super(brand); 18 | this.model = mod; 19 | } 20 | show() { 21 | return this.present() + ', it is a ' + this.model; 22 | } 23 | } 24 | 25 | let myCar = new Model("Toyota", "Camry"); 26 | console.log(myCar.show()); // I have a Camry, it is a Toyota. 27 | ``` 28 | 29 | {% hint style="info" %} 30 | The prototype of the parent class must be an `Object` or `null`. 31 | {% endhint %} 32 | 33 | The `super` method is used inside a constructor and refers to the parent class. With this, one can access the parent class properties and methods. 34 | 35 | -------------------------------------------------------------------------------- /en/classes/static.md: -------------------------------------------------------------------------------- 1 | # Static 2 | 3 | The `static` keyword defines the static methods or properties for a class. These methods and properties are called in the class itself. 4 | 5 | ```javascript 6 | class Car { 7 | constructor(name) { 8 | this.name = name; 9 | } 10 | static hello(x) { 11 | return "Hello " + x.name; 12 | } 13 | } 14 | let myCar = new Car("Toyota"); 15 | 16 | console.log(myCar.hello()); // This will throw an error 17 | console.log(Car.hello(myCar)); 18 | // Result: Hello Toyota 19 | ``` 20 | 21 | {% hint style="info" %} 22 | One can access the static method or property of another static method of the same class using `this` keyword. 23 | {% endhint %} 24 | -------------------------------------------------------------------------------- /en/conditional/README.md: -------------------------------------------------------------------------------- 1 | # Conditional Logic 2 | 3 | A condition is a test for something. Conditions are very important for programming, in several ways: 4 | 5 | First of all, conditions can be used to ensure that your program works, regardless of what data you throw at it for processing. If you blindly trust data, you’ll get into trouble and your programs will fail. If you test that the thing you want to do is possible and has all the required information in the right format, that won’t happen, and your program will be a lot more stable. Taking such precautions is also known as programming defensively. 6 | 7 | The other thing conditions can do for you is allow for branching. You might have encountered branching diagrams before, for example when filling out a form. Basically, this refers to executing different “branches” (parts) of code, depending on if the condition is met or not. 8 | 9 | In this chapter, we'll learn the basis of conditional logic in Javascript. 10 | -------------------------------------------------------------------------------- /en/conditional/comparators.md: -------------------------------------------------------------------------------- 1 | # Comparators 2 | 3 | Lets now focus on the conditional part: 4 | 5 | ```javascript 6 | if (country === "France") { 7 | ... 8 | } 9 | ``` 10 | 11 | The conditional part is the variable `country` followed by the three equal signs (`===`). Three equal signs tests if the variable `country` has both the correct value (`France`) and also the correct type (`String`). You can test conditions with double equal signs, too, however a conditional such as `if (x == 5)` would then return true for both `var x = 5;` and `var x = "5";`. Depending on what your program is doing, this could make quite a difference. It is highly recommended as a best practice that you always compare equality with three equal signs (`===` and `!==`) instead of two (`==` and `!=`). 12 | 13 | Other conditional tests: 14 | 15 | * `x > a`: is x bigger than a? 16 | * `x < a`: is x less than a? 17 | * `x <= a`: is x less than or equal to a? 18 | * `x >=a`: is x greater than or equal to a? 19 | * `x != a`: is x not a? 20 | * `x`: does x exist? 21 | 22 | ## Logical Comparison 23 | 24 | In order to avoid the if-else hassle, simple logical comparisons can be utilised. 25 | 26 | ```javascript 27 | let topper = marks > 85 ? "YES" : "NO"; 28 | ``` 29 | 30 | In the above example, `?` is a logical operator. The code says that if the value of marks is greater than 85 i.e. `marks > 85` , then `topper = YES` ; otherwise `topper = NO` . Basically, if the comparison condition proves true, the first argument is accessed and if the comparison condition is false, the second argument is accessed. 31 | -------------------------------------------------------------------------------- /en/conditional/concatenate.md: -------------------------------------------------------------------------------- 1 | # Concatenate 2 | 3 | Furthermore, you can concatenate different conditions with "`or`" or “`and`” statements, to test whether either statement is true, or both are true, respectively. 4 | 5 | In JavaScript “or” is written as `||` and “and” is written as `&&`. 6 | 7 | Say you want to test if the value of x is between 10 and 20—you could do that with a condition stating: 8 | 9 | ```javascript 10 | if (x > 10 && x < 20) { 11 | ... 12 | } 13 | ``` 14 | 15 | If you want to make sure that country is either “England” or “Germany” you use: 16 | 17 | ```javascript 18 | if (country === "England" || country === "Germany") { 19 | ... 20 | } 21 | ``` 22 | 23 | **Note**: Just like operations on numbers, Conditions can be grouped using parenthesis, ex: `if ( (name === "John" || name === "Jennifer") && country === "France")`. 24 | -------------------------------------------------------------------------------- /en/conditional/else.md: -------------------------------------------------------------------------------- 1 | # Else 2 | 3 | There is also an `else` clause that will be applied when the first condition isn’t true. This is very powerful if you want to react to any value, but single out one in particular for special treatment: 4 | 5 | ```javascript 6 | let umbrellaMandatory; 7 | 8 | if (country === "England") { 9 | umbrellaMandatory = true; 10 | } else { 11 | umbrellaMandatory = false; 12 | } 13 | ``` 14 | 15 | The `else` clause can be joined with another `if`. Let's remake the example from the previous article: 16 | 17 | ```javascript 18 | if (country === "England") { 19 | ... 20 | } else if (country === "France") { 21 | ... 22 | } else if (country === "Germany") { 23 | ... 24 | } 25 | ``` 26 | 27 | {% exercise %} 28 | From the following values write a conditional statement that checks if `num1` is greater than `num2`. If it is, assign "num1 is greater than num2" to the `result` variable. If it is not, assign "num1 is less than or equal to num2". 29 | 30 | {% initial %} 31 | let num1 = 10; 32 | let num2 = 5; 33 | let result; 34 | 35 | // check if num1 is greater than num2 36 | if( condition ) { 37 | 38 | }else { 39 | 40 | } 41 | {% solution %} 42 | let num1 = 10; 43 | let num2 = 5; 44 | let result; 45 | 46 | // check if num1 is greater than num2 47 | if (num1 > num2) { 48 | result = "num1 is greater than num2"; 49 | } else { 50 | result = "num1 is less than or equal to num2"; 51 | } 52 | 53 | {% validation %} 54 | assert(result == "num1 is greater than num2" ); 55 | 56 | {% context %} 57 | {% endexercise %} 58 | -------------------------------------------------------------------------------- /en/conditional/if.md: -------------------------------------------------------------------------------- 1 | # If 2 | 3 | The easiest condition is an if statement and its syntax is `if(condition){ do this … }`. The condition has to be true for the code inside the curly braces to be executed. You can for example test a string and set the value of another string dependent on its value: 4 | 5 | ```javascript 6 | let country = "France"; 7 | let weather; 8 | let food; 9 | let currency; 10 | 11 | if (country === "England") { 12 | weather = "horrible"; 13 | food = "filling"; 14 | currency = "pound sterling"; 15 | } 16 | 17 | if (country === "France") { 18 | weather = "nice"; 19 | food = "stunning, but hardly ever vegetarian"; 20 | currency = "funny, small and colourful"; 21 | } 22 | 23 | if (country === "Germany") { 24 | weather = "average"; 25 | food = "wurst thing ever"; 26 | currency = "funny, small and colourful"; 27 | } 28 | 29 | let message = 30 | "this is " + 31 | country + 32 | ", the weather is " + 33 | weather + 34 | ", the food is " + 35 | food + 36 | " and the " + 37 | "currency is " + 38 | currency; 39 | 40 | console.log(message); 41 | // 'this is France, the weather is nice, the food is stunning, but hardly ever vegetarian and the currency is funny, small and colourful' 42 | ``` 43 | 44 | {% hint style="info" %} 45 | Conditions can also be nested. 46 | {% endhint %} 47 | -------------------------------------------------------------------------------- /en/error-handling/README.md: -------------------------------------------------------------------------------- 1 | # Error Handling 2 | 3 | -------------------------------------------------------------------------------- /en/error-handling/try...-catch.md: -------------------------------------------------------------------------------- 1 | # try... catch 2 | 3 | In programming errors happen for various reasons, some happen from code errors, some due to wrong input, and other unforeseeable things. When an error happens, the code stops and generates an error message usually seen in the console. 4 | 5 | Instead of halting the code execution, we can use the `try...catch` construct that allows catching errors without dying the script. The `try...catch` construct has two main blocks; `try` and then `catch`. 6 | 7 | ```javascript 8 | try { 9 | // code... 10 | } catch (err) { 11 | // error handling 12 | } 13 | ``` 14 | 15 | At first, the code in the `try` block is executed. If no errors are encountered then it skips the `catch` block. If an error occurs then the `try` execution is stopped, moving the control sequence to the `catch` block. The cause of the error is captured in `err` variable. 16 | 17 | ```javascript 18 | try { 19 | // code... 20 | alert('Welcome to Learn JavaScript'); 21 | asdk; // error asdk variable is not defined 22 | } catch (err) { 23 | console.log("Error has occurred"); 24 | } 25 | ``` 26 | 27 | {% hint style="warning" %} 28 | `try...catch` works for runtime errors meaning that the code must be runnable and synchronous. 29 | {% endhint %} 30 | 31 | To throw a custom error, a `throw` statement can be used. The error object, that gets generated by errors has two main properties. 32 | 33 | * **name**: error name 34 | * **message**: details about the error 35 | 36 | {% hint style="info" %} 37 | If we don't need an `error` message catch can omit it. 38 | {% endhint %} 39 | -------------------------------------------------------------------------------- /en/error-handling/try...catch...finally.md: -------------------------------------------------------------------------------- 1 | # try...catch...finally 2 | 3 | We can add one more construct to `try...catch` called `finally`, this code executes in all cases. i.e. after `try` when there is no error and after a `catch` in case of error. The syntax for `try ...catch...finally` is shown below. 4 | 5 | ```javascript 6 | try { 7 | // try to execute the code 8 | } catch (err) { 9 | // handle errors 10 | } finally { 11 | // execute always 12 | } 13 | ``` 14 | 15 | Running real-world example code. 16 | 17 | ```javascript 18 | try { 19 | alert( 'try' ); 20 | } catch (err) { 21 | alert( 'catch' ); 22 | } finally { 23 | alert( 'finally' ); 24 | } 25 | ``` 26 | 27 | In the above example, the `try` block is executed first which is then followed by `finally` as there are no errors. 28 | 29 | {% exercise %} 30 | Write a function `divideNumbers()` that takes two arguments numerator and denominator and returns the result of dividing numerator by denominator using following settings. 31 | 32 | {% initial %} 33 | function divideNumbers(numerator, denominator) { 34 | try { 35 | // try statement to divide numerator by denominator. 36 | } catch (error) { 37 | // print error message 38 | } finally { 39 | // print execution has finished 40 | } 41 | // return result 42 | } 43 | let answer = divideNumbers(10, 2); 44 | 45 | {% solution %} 46 | function divideNumbers(numerator, denominator) { 47 | let result; 48 | try { 49 | result = numerator / denominator; 50 | } catch (error) { 51 | console.error(`Error: ${error}`); 52 | } finally { 53 | console.log('Function finished executing'); 54 | } 55 | return result; 56 | } 57 | let answer = divideNumbers(10, 2); 58 | {% validation %} 59 | assert(answer == 5); 60 | 61 | {% context %} 62 | {% endexercise %} 63 | -------------------------------------------------------------------------------- /en/exercises/README.md: -------------------------------------------------------------------------------- 1 | # Exercises 2 | 3 | -------------------------------------------------------------------------------- /en/exercises/concatenation.md: -------------------------------------------------------------------------------- 1 | # Concatenation 2 | 3 | In any programming language, string concatenation simply means appending one or more strings to another string. For example, when strings "_World_" and "_Good Afternoon_" are concatenated with string "_Hello_", they form the string "_Hello World, Good Afternoon_". We can concatenate a string in several ways in JavaScript. 4 | 5 | ### Example: 6 | 7 | ```javascript 8 | const icon = '👋'; 9 | 10 | // using template Strings 11 | `hi ${icon}`; 12 | 13 | // using join() Method 14 | ['hi', icon].join(' '); 15 | 16 | // using concat() Method 17 | ''.concat('hi ', icon); 18 | 19 | // using + operator 20 | 'hi ' + icon; 21 | 22 | // RESULT 23 | // hi 👋 24 | ``` 25 | 26 | ### 📝 Task: 27 | 28 | * [ ] Write a program to set the values for `str1`and `str2` so the code prints '_Hello World_' to the console. 29 | 30 | ### 💡 Hints: 31 | 32 | * Visit the [concatenation](../strings/concat.md) chapter of strings for more info about string concatenation. 33 | -------------------------------------------------------------------------------- /en/exercises/conditional-statements.md: -------------------------------------------------------------------------------- 1 | # Conditional Statements 2 | 3 | Conditional logic is vital in programming as it makes sure that the program works regardless of what data you throw in and also allows branching. This exercise is about the implementation of various conditional logic in real-life problems. 4 | 5 | ### 📝 Task: 6 | 7 | * [ ] Write a program to create a prompt "_How many km is left to go?_" and based on the user and the following conditions, print the results in the `console`. 8 | * If there are more than 100 km left to go, print: `"You still have a bit of driving left to go"`. 9 | * If there are more than 50 km, but less or equal to 100 km, print: `"I'll be there in 5 minutes"`. 10 | * If there are less than or equal to 50 km, print: `"I'm parking. I'll see you right now"`. 11 | 12 | ### 💡 Hints: 13 | 14 | * Visit the [conditional logic](../conditional/) chapter to understand how to use conditional logic and conditional statements. 15 | -------------------------------------------------------------------------------- /en/exercises/console.md: -------------------------------------------------------------------------------- 1 | # Console 2 | 3 | In JavaScript, we use `console.log()` to write a message (the content of a variable, a given string, etc.) in `console`. It is mainly used for debugging purposes, ideally to leave a trace of the content of variables during the execution of a program. 4 | 5 | ### Example: 6 | 7 | ```javascript 8 | console.log("Welcome to Learn JavaScript Beginners Edition"); 9 | let age = 30; 10 | console.log(age); 11 | ``` 12 | 13 | ### 📝 Tasks: 14 | 15 | * [ ] Write a program to print `Hello World` on the console. Feel free to try other things as well! 16 | * [ ] Write a program to print variables to the `console`. 17 | 1. Declare a variable `animal` and assign the dragon value to it. 18 | 2. Print the `animal` variable to the `console`. 19 | 20 | ### 💡 Hints: 21 | 22 | * Visit the [variabl](../basics/variables.md)[e](../basics/variables.md) chapter to understand more about variables. 23 | -------------------------------------------------------------------------------- /en/exercises/constants.md: -------------------------------------------------------------------------------- 1 | # Constants 2 | 3 | Constants were introduced in ES6(2015), and use a `const` keyword. Variables that are declared with `const` cannot be reassigned or redeclared. 4 | 5 | ### Example: 6 | 7 | ```javascript 8 | const VERSION = '1.2'; 9 | ``` 10 | 11 | ### 📝 Task: 12 | 13 | * [ ] Run the program mentioned below and fix the error that you see in the console. Make sure that the code result is `0.9` when it is fixed in the console. 14 | 15 | ```javascript 16 | const VERSION = '0.7'; 17 | VERSION = '0.9'; 18 | console.log(VERSION); 19 | ``` 20 | 21 | ### 💡 Hints: 22 | 23 | * Visit the [Variables](../basics/variables.md) chapter for more info about const and also look for "_TypeError assignment to constant variable_" in search engines to learn a fix. 24 | -------------------------------------------------------------------------------- /en/exercises/fizzbuzz-problem.md: -------------------------------------------------------------------------------- 1 | # FizzBuzz Problem 2 | 3 | The _FizzBuzz_ problem is one of the commonly asked questions, here one has to print _Fizz_ and _Buzz_ upon some conditions. 4 | 5 | ### 📝 Tasks: 6 | 7 | * [ ] Write a program to print all the numbers between 1 to 100 in such a way that the following conditions are met. 8 | * For multiples of 3, instead of the number, print `Fizz`. 9 | * For multiples of 5, print `Buzz`. 10 | * For numbers that are multiples of both 3 and 5, print `FizzBuzz`. 11 | 12 | ```javascript 13 | / 14 | 1 15 | 2 16 | Fizz 17 | 4 18 | Buzz 19 | Fizz 20 | 7 21 | 8 22 | Fizz 23 | Buzz 24 | 11 25 | Fizz 26 | 13 27 | 14 28 | FizzBuzz 29 | 16 30 | .... 31 | .... 32 | 98 33 | Fizz 34 | Buzz 35 | / 36 | ``` 37 | 38 | ### 💡 Hints: 39 | 40 | * Visit the [loops](../loops/) chapter to understand how the loop works. 41 | -------------------------------------------------------------------------------- /en/exercises/functions.md: -------------------------------------------------------------------------------- 1 | # Functions 2 | 3 | A function is a block of code designed to perform a specific task and executed when "something" invokes it. More info about functions can be found in the[ functions](../functions/) chapter. 4 | 5 | 6 | 7 | ### 📝 Task: 8 | 9 | * [ ] Write a program to create a function named `isOdd`that passes a number `45345` as an argument and determines whether the number is odd or not. 10 | * [ ] Call this function to get the result. The result should be in a boolean format and should return `true` in `console`. 11 | 12 | ### 💡 Hints: 13 | 14 | * Visit the [functions](../functions/) chapter to understand functions and how to create them. 15 | -------------------------------------------------------------------------------- /en/exercises/get-the-titles.md: -------------------------------------------------------------------------------- 1 | # Get the Titles! 2 | 3 | The _Get the Tiles!_ problem is an interesting problem where we have to get the title from a list of books. This is a good exercise for the implementation of arrays and objects. 4 | 5 | ### 📝 Tasks: 6 | 7 | Given an array of objects that represent books with an author. 8 | 9 | ```javascript 10 | const books = [ 11 | { 12 | title: "Eloquent JavaScript, Third Edition", 13 | author: "Marijn Haverbeke" 14 | }, 15 | { 16 | title: "Practical Modern JavaScript", 17 | author: "Nicolás Bevacqua" 18 | } 19 | ] 20 | ``` 21 | 22 | * [ ] Write a program to create a function `getTheTitles` that takes the array and returns the array of title and print its value in the `console`. 23 | 24 | ### 💡 Hints: 25 | 26 | * Visit the [arrays](../arrays/) and [objects](../objects/) chapter to understand how the array and object work. 27 | 28 | -------------------------------------------------------------------------------- /en/exercises/multiplication.md: -------------------------------------------------------------------------------- 1 | # Multiplication 2 | 3 | In JavaScript, we can perform the multiplication of two numbers by using the asterisk `(*)` arithmetic operators. 4 | 5 | ### Example: 6 | 7 | ```javascript 8 | let resultingValue = 3 * 2; 9 | ``` 10 | 11 | Here, we stored the product of `3 * 2` into a `resultingValue` variable. 12 | 13 | ### 📝 Tasks: 14 | 15 | * [ ] Write a program to store the product of `23` times `41` and print its value. 16 | 17 | ### 💡 Hints: 18 | 19 | * Visit the [Basic Operators](../numbers/operators.md) chapter to understand the mathematical operations. 20 | -------------------------------------------------------------------------------- /en/exercises/objects.md: -------------------------------------------------------------------------------- 1 | # Objects 2 | 3 | Objects are the collection of `key`, `value` pairs and each pair of key-value are known as a property. Here, the property of the `key` can be a `string` whereas its `value` can be of any value. 4 | 5 | ### 📝 Tasks: 6 | 7 | Given a Doe family that includes two-member, where each member's information is provided in form of an object. 8 | 9 | ```javascript 10 | let person = { 11 | name: "John", //String 12 | lastName: "Doe", 13 | age: 35, //Number 14 | gender: "male", 15 | luckyNumbers: [ 7, 11, 13, 17], //Array 16 | significantOther: person2 //Object, 17 | }; 18 | 19 | let person2 = { 20 | name: "Jane", 21 | lastName: "Doe", 22 | age: 38, 23 | gender: "female", 24 | luckyNumbers: [ 2, 4, 6, 8], 25 | significantOther: person 26 | }; 27 | 28 | let family = { 29 | lastName: "Doe", 30 | members: [person, person2] //Array of objects 31 | }; 32 | ``` 33 | 34 | * [ ] Find a way to print the name of the first member of the Doe family in a `console`. 35 | * [ ] Change the fourth `luckyNumbers` of the second member of the Doe family to `33`. 36 | * [ ] Add a new member to the family by creating a new person (`Jimmy,` `Doe`, `13`, `male`, `[1, 2, 3, 4]`, `null`) and update the member list. 37 | * [ ] Print the `SUM` of the lucky numbers of Doe family in the `console`. 38 | 39 | ### 💡 Hints: 40 | 41 | * Visit the [objects](../objects/) chapter to understand how the object work. 42 | * You can get `luckyNumbers` from each person object inside the family object. 43 | * Once you get each array just loop over it adding every element and then add each sum of the 3 family members. 44 | -------------------------------------------------------------------------------- /en/exercises/user-input-variables.md: -------------------------------------------------------------------------------- 1 | # User Input Variables 2 | 3 | In JavaScript, we can take input from users and use it as a variable. One doesn't need to know their value to work with them. 4 | 5 | ### 📝 Tasks: 6 | 7 | * [ ] Write a program to take input from a user and add `10` to it, and print its result. 8 | 9 | ### 💡 Hints: 10 | 11 | * The content of a variable is determined by the user's inputs. The `prompt()` method saves the input value as a string. 12 | * You will need to make sure that the string value is converted into an integer for calculations. 13 | * Visit the [Basic Operators](../numbers/operators.md) chapter for the type conversion of `string` to `int`. 14 | -------------------------------------------------------------------------------- /en/functions/README.md: -------------------------------------------------------------------------------- 1 | # Functions 2 | 3 | Functions are one of the most powerful and essential notions in programming. Functions like mathematical functions perform transformations, they take input values called **arguments** and **return** an output value. 4 | 5 | Functions can be created in two ways: using `function declaration` or `function expression` . The _function name_ can be omitted in f`unction expression` making it an `anonymous function`. Functions, like variables, must be declared. Let's declare a function `double` that accepts an _argument_ called `x` and **returns** the double of x : 6 | 7 | ```javascript 8 | // an example of a function declaration 9 | function double(x) { 10 | return 2 * x; 11 | } 12 | ``` 13 | 14 | > _Note:_ the function above **may** be referenced before it has been defined. 15 | 16 | Functions are also values in JavaScript; they can be stored in variables (just like numbers, strings, etc ...) and given to other functions as arguments : 17 | 18 | ```javascript 19 | // an example of a function expression 20 | let double = function (x) { 21 | return 2 * x; 22 | }; 23 | ``` 24 | 25 | > _Note:_ the function above **may not** be referenced before it is defined, just like any other variable. 26 | 27 | {% hint style="info" %} 28 | A callback is a function passed as an argument to another function. 29 | {% endhint %} 30 | 31 | An arrow function is a compact alternative to traditional functions which has some semantic differences with some limitations. These function doesn't have their own bindings to `this`, `arguments` and `super`, and cannot be used as constructors. An example of an arrow function. 32 | 33 | ```javascript 34 | const double = (x) => 2 * x; 35 | ``` 36 | 37 | {% hint style="warning" %} 38 | The `this` keyword in the arrow function represents the object that defined the arrow function. 39 | {% endhint %} 40 | -------------------------------------------------------------------------------- /en/json.md: -------------------------------------------------------------------------------- 1 | # JSON 2 | 3 | **J**ava**S**cript **O**bject **N**otation (JSON) is a text-based format for storing and transporting data. The Javascript Objects can be easily converted into JSON and vice versa. For example. 4 | 5 | ```javascript 6 | // a JavaScript object 7 | let myObj = { name:"Ryan", age:30, city:"Austin" }; 8 | 9 | // converted into JSON: 10 | let myJSON = JSON.stringify(myObj); 11 | console.log(myJSON); 12 | // Result: '{"name":"Ryan","age":30,"city":"Austin"}' 13 | 14 | //converted back to JavaScript object 15 | let originalJSON = JSON.parse(myJSON); 16 | console.log(originalJSON); 17 | 18 | // Result: {name: 'Ryan', age: 30, city: 'Austin'} 19 | ``` 20 | 21 | 22 | 23 | `stringify` and `parse` are the two methods supported by JSON. 24 | 25 | | Method | Description | 26 | | ------------- | ------------------------------------------------------ | 27 | | `parse()` | Returns JavaScript object from the parsed JSON string | 28 | | `stringify()` | Returns JSON string from JavaScript Object | 29 | 30 | 31 | 32 | The following data types are supported by JSON. 33 | 34 | * string 35 | * number 36 | * array 37 | * boolean 38 | * object with valid JSON values 39 | * `null` 40 | 41 | It can not be `function`, `date` or `undefined`. 42 | 43 | -------------------------------------------------------------------------------- /en/loops/README.md: -------------------------------------------------------------------------------- 1 | # Loops 2 | 3 | Loops are repetitive conditions where one variable in the loop changes. Loops are handy, if you want to run the same code over and over again, each time with a different value. 4 | 5 | Instead of writing: 6 | 7 | ```javascript 8 | doThing(cars[0]); 9 | doThing(cars[1]); 10 | doThing(cars[2]); 11 | doThing(cars[3]); 12 | doThing(cars[4]); 13 | ``` 14 | 15 | You can write: 16 | 17 | ```javascript 18 | for (var i = 0; i < cars.length; i++) { 19 | doThing(cars[i]); 20 | } 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /en/loops/dowhile.md: -------------------------------------------------------------------------------- 1 | # Do...While 2 | 3 | The do...while statement creates a loop that executes a specified statement until the test condition evaluates to be false. The condition is evaluated after executing the statement. The syntax for do... while is 4 | 5 | ```javascript 6 | do { 7 | // statement 8 | } while (expression); 9 | ``` 10 | 11 | Lets for example see how to print numbers less than 10 using `do...while` loop: 12 | 13 | ```javascript 14 | var i = 0; 15 | do { 16 | document.write(i + " "); 17 | i++; // incrementing i by 1 18 | } while (i < 10); 19 | ``` 20 | 21 | > _**Note**_: `i = i + 1` can be written `i++`. 22 | 23 | -------------------------------------------------------------------------------- /en/loops/for.md: -------------------------------------------------------------------------------- 1 | # For 2 | 3 | The easiest form of a loop is the for statement. This one has a syntax that is similar to an if statement, but with more options: 4 | 5 | ```javascript 6 | for (condition; end condition; change) { 7 | // do it, do it now 8 | } 9 | ``` 10 | 11 | Let's see how to execute the same code ten-times using a `for` loop: 12 | 13 | ```javascript 14 | for (let i = 0; i < 10; i = i + 1) { 15 | // do this code ten-times 16 | } 17 | ``` 18 | 19 | > _**Note**_: `i = i + 1` can be written `i++`. 20 | 21 | To loop through the properties of an object or an array `for in` loop can also be used. 22 | 23 | ```javascript 24 | for (key in object) { 25 | // code block to be executed 26 | } 27 | ``` 28 | 29 | Examples of `for in` loop for an object and array is shown below: 30 | 31 | ```javascript 32 | const person = {fname:"John", lname:"Doe", age:25}; 33 | let info = ""; 34 | for (let x in person) { 35 | info += person[x]; 36 | } 37 | 38 | // Result: info = "JohnDoe25" 39 | 40 | const numbers = [45, 4, 9, 16, 25]; 41 | let txt = ""; 42 | for (let x in numbers) { 43 | txt += numbers[x]; 44 | } 45 | 46 | // Result: txt = '45491625' 47 | ``` 48 | 49 | The value of iterable objects such as `Arrays`, `Strings`, `Maps`, `NodeLists` can be looped using `for of` statement. 50 | 51 | ```javascript 52 | let language = "JavaScript"; 53 | let text = ""; 54 | for (let x of language) { 55 | text += x; 56 | } 57 | ``` 58 | -------------------------------------------------------------------------------- /en/loops/while.md: -------------------------------------------------------------------------------- 1 | # While 2 | 3 | While Loops repetitively execute a block of code as long as a specified condition is true. 4 | 5 | ```javascript 6 | while (condition) { 7 | // do it as long as condition is true 8 | } 9 | ``` 10 | 11 | For example, the loop in this example will repetitively execute its block of code as long as the variable i is less than 5: 12 | 13 | ```javascript 14 | var i = 0, 15 | x = ""; 16 | while (i < 5) { 17 | x = x + "The number is " + i; 18 | i++; 19 | } 20 | ``` 21 | 22 | {% hint style="warning" %} 23 | Be careful to avoid infinite looping if the condition is always true! 24 | {% endhint %} 25 | -------------------------------------------------------------------------------- /en/miscellaneous/README.md: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | 3 | -------------------------------------------------------------------------------- /en/miscellaneous/hoisting.md: -------------------------------------------------------------------------------- 1 | # Hoisting 2 | 3 | Hosting is a default behavior in JavaScript of moving declarations at the top. While executing a code, it creates a global execution context: creation and execution. In the creation phase, JavaScript moves the variable and function declaration to the top of the page, which is known as hoisting. 4 | 5 | ```javascript 6 | // variable hoisting 7 | console.log(counter); 8 | let counter = 1; // throws ReferenceError: Cannot access 'counter' before initialization 9 | ``` 10 | 11 | Although the `counter` is present in the heap memory but hasn't been initialized so, it throws an error. This happens because of hoisting, the `counter` variable is hoisted here. 12 | 13 |
// function hoisting
14 | const x = 20,
15 |     y = 10;
16 | 
17 | let result = add(x,y); // ❌ Uncaught ReferenceError: add is not defined
18 | console.log(result);
19 | 
20 | let add = (x, y) => x + y; 
21 | 
22 | 23 | Here, the `add` function is hoisted and initialized with `undefined` in heap memory in the creation phase of the global execution context. Thus, throwing an error. 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /en/miscellaneous/template-literals.md: -------------------------------------------------------------------------------- 1 | # Template Literals 2 | 3 | Template literals are literals delaminated with backtick `(``)` and are used in variable and expression interpolation into strings. 4 | 5 | ```javascript 6 | let text = `Hello World!`; 7 | // template literals with both single and double code inside a single string 8 | let text = `He's often called "Johnny"`; 9 | // template literals with multiline strings 10 | let text = 11 | `The quick 12 | brown fox 13 | jumps over 14 | the lazy dog`; 15 | 16 | // template literals with variable interpolation 17 | const firstName = "John"; 18 | const lastName = "Doe"; 19 | 20 | const welcomeText = `Welcome ${firstName}, ${lastName}!`; 21 | 22 | // template literals with expression interpolation 23 | const price = 10; 24 | const VAT = 0.25; 25 | 26 | const total = `Total: ${(price * (1 + VAT)).toFixed(2)}`; 27 | ``` 28 | 29 | 30 | -------------------------------------------------------------------------------- /en/numbers/README.md: -------------------------------------------------------------------------------- 1 | # Numbers 2 | 3 | JavaScript has **only one type of number** – 64-bit float point. It's the same as Java's `double`. Unlike most other programming languages, there is no separate integer type, so 1 and 1.0 are the same value. Creating a number is easy, it can be done just like for any other variable type using the `var` keyword. 4 | 5 | Numbers can be created from a constant value: 6 | 7 | ```javascript 8 | // This is a float: 9 | let a = 1.2; 10 | 11 | // This is an integer: 12 | let b = 10; 13 | ``` 14 | 15 | Or from the value of another variable: 16 | 17 | ```javascript 18 | let a = 2; 19 | let b = a; 20 | ``` 21 | 22 | The precision of integers is accurate up to 15 digits and the maximum number is 17. 23 | 24 | ```javascript 25 | let x = 999999999999999; // x will be 999999999999999 26 | let y = 9999999999999999; // y will be 10000000000000000 27 | ``` 28 | 29 | It interprets numeric constants as hexadecimal if they are preceded by `0x`. 30 | 31 | ```javascript 32 | let z = 0xFF; // 255 33 | ``` 34 | -------------------------------------------------------------------------------- /en/objects/README.md: -------------------------------------------------------------------------------- 1 | # Objects 2 | 3 | In javascript the objects are **mutable** because we change the values pointed by the reference object, instead, when we change a primitive value we are changing its reference which now is pointing to the new value and so primitive are **immutable**. The primitive types of JavaScript are `true`, `false`, numbers, strings, `null` and `undefined`. Every other value is an `object`.Objects contain `propertyName`: `propertyValue` pairs. There are three ways to create an `object` in JavaScript: 4 | 5 | 1. literal 6 | 7 | ```javascript 8 | let object = {}; 9 | // Yes, simply a pair of curly braces! 10 | ``` 11 | 12 | > _**Note:**_ this is the **recommended** way. 13 | 2. object-oriented 14 | 15 | ```javascript 16 | let object = new Object(); 17 | ``` 18 | 19 | > _**Note:**_ it's almost like Java. 20 | 3. and using `object.create` 21 | 22 | ```javascript 23 | let object = Object.create(proto[, propertiesObject]); 24 | ``` 25 | 26 | > _**Note:**_ it creates a new object with the specified prototype object and properties. 27 | -------------------------------------------------------------------------------- /en/objects/delete.md: -------------------------------------------------------------------------------- 1 | # Delete 2 | 3 | A `delete` property can be used to **remove a property** from an object. When a property is deleted, it is removed from the object and cannot be accessed or enumerated (i.e., it does not show up in a for-in loop). 4 | 5 | Here's the syntax for using `delete`: 6 | 7 | ```javascript 8 | delete object.property; 9 | ``` 10 | 11 | For example: 12 | 13 | ```javascript 14 | let adult = { age: 26 }, 15 | child = Object.create(adult); 16 | 17 | child.age = 8; 18 | 19 | delete child.age; 20 | 21 | /* Remove age property from child, revealing the age of the prototype, because then it is not overriden. */ 22 | 23 | let prototypeAge = child.age; 24 | // 26, because child does not have its own age property. 25 | ``` 26 | 27 | {% hint style="warning" %} 28 | The `delete` operator only works on own properties of an object, and not on inherited properties. It also does not work on properties that have the `configurable` attribute set to `false`. 29 | {% endhint %} 30 | 31 | The `delete` operator does not modify the object's prototype chain. It simply removes the specified property from the object and also it does not actually destroy the object or its properties. It simply makes the properties inaccessible. If you need to destroy an object and release its memory, you can set the object to `null` or use a garbage collector to reclaim the memory. 32 | -------------------------------------------------------------------------------- /en/objects/enumeration.md: -------------------------------------------------------------------------------- 1 | # Enumeration 2 | 3 | _Enumeration_ refers to the process of iterating over the properties of an object and performing a certain action for each property. There are several ways to enumerate the properties of an object in JavaScript. 4 | 5 | One way to enumerate the properties of an object is to use the `for-in` loop. The `for-in` loop iterates over the enumerable properties of an object in an arbitrary order, and for each property it executes a given block of code. 6 | 7 | The `for in` statement can loop over all of the property names in an object. The enumeration will include functions and prototype properties. 8 | 9 | ```javascript 10 | let fruit = { 11 | apple: 2, 12 | orange: 5, 13 | pear: 1, 14 | }, 15 | sentence = "I have ", 16 | quantity; 17 | for (kind in fruit) { 18 | quantity = fruit[kind]; 19 | sentence += quantity + " " + kind + (quantity === 1 ? "" : "s") + ", "; 20 | } 21 | // The following line removes the trailing comma. 22 | sentence = sentence.substr(0, sentence.length - 2) + "."; 23 | // I have 2 apples, 5 oranges, 1 pear. 24 | ``` 25 | 26 | Another way to enumerate the properties of an object is to use the `Object.keys()` method, which returns an array of the object's own enumerable property names. 27 | 28 | For example: 29 | 30 | ```typescript 31 | let object = { 32 | foo: 'bar', 33 | baz: 'qux' 34 | }; 35 | 36 | let properties = Object.keys(object); 37 | properties.forEach(function(property) { 38 | console.log(property + ': ' + object[property]); 39 | }); 40 | 41 | // foo: bar 42 | // baz: qux 43 | ``` 44 | -------------------------------------------------------------------------------- /en/objects/mutable.md: -------------------------------------------------------------------------------- 1 | # Mutable 2 | 3 | The difference between objects and primitive values is that **we can change objects**, whereas primitive values are **immutable**. 4 | 5 | For example: 6 | 7 | ```javascript 8 | let myPrimitive = "first value"; 9 | myPrimitive = "another value"; 10 | // myPrimitive now points to another string. 11 | let myObject = { key: "first value" }; 12 | myObject.key = "another value"; 13 | // myObject points to the same object. 14 | ``` 15 | 16 | You can add, modify, or delete properties of an object using the dot notation or the square bracket notation. 17 | 18 | ```python 19 | let object = {}; 20 | object.foo = 'bar'; // Add property 'foo' 21 | object['baz'] = 'qux'; // Add property 'baz' 22 | object.foo = 'quux'; // Modify property 'foo' 23 | delete object.baz; // Delete property 'baz' 24 | ``` 25 | 26 | {% hint style="warning" %} 27 | Primitive values (such as numbers and strings) are immutable, while objects (such as arrays and objects) are mutable. 28 | {% endhint %} 29 | -------------------------------------------------------------------------------- /en/objects/properties.md: -------------------------------------------------------------------------------- 1 | # Properties 2 | 3 | Object's property is a `propertyName`: `propertyValue` pair, where **property name can be only a string**. If it's not a string, it gets casted into a string. You can specify properties **when creating** an object **or later**. There may be zero or more properties separated by commas. 4 | 5 | ```javascript 6 | let language = { 7 | name: "JavaScript", 8 | isSupportedByBrowsers: true, 9 | createdIn: 1995, 10 | author: { 11 | firstName: "Brendan", 12 | lastName: "Eich", 13 | }, 14 | // Yes, objects can be nested! 15 | getAuthorFullName: function () { 16 | return this.author.firstName + " " + this.author.lastName; 17 | }, 18 | // Yes, functions can be values too! 19 | }; 20 | ``` 21 | 22 | The following code demonstrates how to **get** a property's value. 23 | 24 | ```javascript 25 | let variable = language.name; 26 | // variable now contains "JavaScript" string. 27 | variable = language["name"]; 28 | // The lines above do the same thing. The difference is that the second one lets you use litteraly any string as a property name, but it's less readable. 29 | variable = language.newProperty; 30 | // variable is now undefined, because we have not assigned this property yet. 31 | ``` 32 | 33 | The following example shows how to **add** a new property **or change** an existing one. 34 | 35 | ```javascript 36 | language.newProperty = "new value"; 37 | // Now the object has a new property. If the property already exists, its value will be replaced. 38 | language["newProperty"] = "changed value"; 39 | // Once again, you can access properties both ways. The first one (dot notation) is recomended. 40 | ``` 41 | -------------------------------------------------------------------------------- /en/promise-async-await/README.md: -------------------------------------------------------------------------------- 1 | # Promise, async/await 2 | 3 | -------------------------------------------------------------------------------- /en/promise-async-await/async-await.md: -------------------------------------------------------------------------------- 1 | # Async/Await 2 | 3 | With promises, one can use a `async` keyword to declare an asynchronous function that returns a promise whereas the `await` syntax makes JavaScript wait until that promise settles and returns its value. These keywords make promises easier to write. An example of async is shown below. 4 | 5 | ```javascript 6 | //async function f 7 | async function f() { 8 | return 1; 9 | } 10 | // promise being resolved 11 | f().then(alert); // 1 12 | ``` 13 | 14 | The above example can be written as follows: 15 | 16 | ```javascript 17 | function f() { 18 | return Promise.resolve(1); 19 | } 20 | 21 | f().then(alert); // 1 22 | ``` 23 | 24 | `async` ensures that the function returns a promise, and wraps non-promises in it. With `await`, we can make JavaScript wait until the promise is settled with its value returned. 25 | 26 | ```javascript 27 | async function f() { 28 | let promise = new Promise((resolve, reject) => { 29 | setTimeout(() => resolve("Welcome to Learn JavaScript!"), 1000) 30 | }); 31 | 32 | let result = await promise; // wait until the promise resolves (*) 33 | alert(result); // "Welcome to Learn JavaScript!" 34 | } 35 | 36 | f(); 37 | ``` 38 | 39 | {% hint style="warning" %} 40 | The `await` keyword can only be used inside an `async` function. 41 | {% endhint %} 42 | -------------------------------------------------------------------------------- /en/strings/concat.md: -------------------------------------------------------------------------------- 1 | # Concatenation 2 | 3 | Concatenation involves adding two or more strings together, creating a larger string containing the combined data of those original strings. The concatenation of a string appends one or more strings to another string. This is done in JavaScript using the following ways. 4 | 5 | * using the **`+`** operator 6 | * using the `concat()` method 7 | * using the array `join()` method 8 | * using the template literal (introduced in ES6) 9 | 10 | The string `concat()` method accepts the list of strings as parameters and returns a new string after concatenation i.e. combination of all the strings. Whereas the array `join()` method is used to concatenate all the elements present in an array by converting them into a single string. 11 | 12 | The template literal uses backtick `(``)` and provides an easy way to create multiline strings and perform string interpolation. An expression can be used inside the backtick using `$` sign and curly braces `$(expression}`. 13 | 14 | ```javascript 15 | const icon = '👋'; 16 | // using template Strings 17 | `hi ${icon}`; 18 | 19 | // using join() Method 20 | ['hi', icon].join(' '); 21 | 22 | // using concat() Method 23 | ''.concat('hi ', icon); 24 | 25 | // using + operator 26 | 'hi ' + icon; 27 | // hi 👋 28 | ``` 29 | -------------------------------------------------------------------------------- /en/strings/length.md: -------------------------------------------------------------------------------- 1 | # Length 2 | 3 | It's easy in Javascript to know how many characters are in a string using the property `.length`. The `length` property returns the number of characters in the string, including spaces and special characters. 4 | 5 | ```javascript 6 | 7 | let size = "Our lovely string".length; 8 | console.log(size); 9 | // size: 17 10 | 11 | let emptyStringSize = "".length 12 | console.log(emptyStringSize); 13 | // emptyStringSize: 0 14 | 15 | ``` 16 | 17 | The length property of an empty string is `0`. 18 | 19 | {% hint style="warning" %} 20 | The `length` property is a read-only property, so you cannot assign a new value to it. 21 | {% endhint %} 22 | -------------------------------------------------------------------------------- /en/strings/replace.md: -------------------------------------------------------------------------------- 1 | # Replace 2 | 3 | The `replace` method allows us to replace a character, word, or sentence with a string. For example. 4 | 5 | ```javascript 6 | let str = "Hello World!"; 7 | let new_str = str.replace("Hello", "Hi"); 8 | 9 | console.log(new_str); 10 | 11 | // Result: Hi World! 12 | ``` 13 | 14 | {% hint style="warning" %} 15 | To replace a value on all instances of a [regular expression](../regular-expression.md) with a `g` modifier is set. 16 | {% endhint %} 17 | 18 | It searches for a string for a value or a regular expression and returns a new string with the value(s) replaced. It doesn't change the original string. Let's see the global case-insensitive replacement example. 19 | 20 | ```javascript 21 | let text = "Mr Blue has a blue house and a blue car"; 22 | let result = text.replace(/blue/gi, "red"); 23 | 24 | console.log(result); 25 | //Result: Mr red has a red house and a red car 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /en/template-literals/currying.md: -------------------------------------------------------------------------------- 1 | # Currying 2 | 3 | `Currying` is an advanced technique in functional programming of transforming a function with multiple arguments into a sequence of nesting functions. It transforms a function from callable `f(a,b,c)` into callable as `f(a)(b)(c)`. It doesn’t call a function instead it transforms it. 4 | 5 | To get a better understanding of currying let’s create a simple `add` function add that takes three arguments and returns the sum of them. Then, we create a `addCurry` function that takes a single input and returns a series of functions with its sum. 6 | 7 | ```javascript 8 | // Noncurried version 9 | const add = (a, b, c)=>{ 10 | return a+ b + c 11 | } 12 | console.log(add(2, 3, 5)) // 10 13 | 14 | // Curried version 15 | const addCurry = (a) => { 16 | return (b)=>{ 17 | return (c)=>{ 18 | return a+b+c 19 | } 20 | } 21 | } 22 | console.log(addCurry(2)(3)(5)) // 10 23 | ``` 24 | 25 | Here, we can see that both the curried and noncurried versions returned the same result. Currying can be beneficial for many reasons, some of which are mentioned here. 26 | 27 | * It helps to avoid passing the same variable again and again. 28 | * It divides the function into smaller chunks with a single responsibility, making the function less error-prone. 29 | * It is used in functional programming to create a high-order function. 30 | -------------------------------------------------------------------------------- /en/template-literals/debugging.md: -------------------------------------------------------------------------------- 1 | # Debugging 2 | 3 | In programming, errors can occur while writing code. It could be due to syntactical or logical errors. The process of finding errors can be time-consuming and tricky and is called code debugging. 4 | 5 | Fortunately, most modern browsers come with built-in debuggers. These debuggers can be switched on and off, forcing errors to be reported. It is also possible to set up breakpoints during the execution of code to stop execution and examine variables. For this one has to open a debugging window and place the `debugger` keyword in the JavaScript code. The code execution is stopped in each breakpoint, allowing developers to examine the JavaScript values and, resume the execution of code. 6 | 7 | One can also use the `console.log()` method to print the JavaScript values in the debugger window. 8 | 9 | ```javascript 10 | const a = 5, b = 6; 11 | const c = a + b; 12 | console.log(c); 13 | // Result : c = 11; 14 | ``` 15 | -------------------------------------------------------------------------------- /en/template-literals/global-footprint.md: -------------------------------------------------------------------------------- 1 | # Global footprint 2 | 3 | If you are developing a module, which might be running on a web page, which also runs other modules, then you must beware of the variable name overlapping. 4 | 5 | Suppose we are developing a counter module: 6 | 7 | ```javascript 8 | let myCounter = { 9 | number: 0, 10 | plusPlus: function () { 11 | this.number = this.number + 1; 12 | }, 13 | isGreaterThanTen: function () { 14 | return this.number > 10; 15 | }, 16 | }; 17 | ``` 18 | 19 | > _**Note:**_ this technique is often used with closures, to make the internal state immutable from the outside. 20 | 21 | The module now takes only one variable name — `myCounter`. If any other module on the page makes use of such names like `number` or `isGreaterThanTen` then it's perfectly safe because we will not override each other's values. 22 | -------------------------------------------------------------------------------- /en/template-literals/linked-list/README.md: -------------------------------------------------------------------------------- 1 | # Linked List 2 | 3 | It is a common data structure found in all programming languages. A Linked List is very similar to a normal array in Javascript, it just acts a little bit differently. 4 | 5 | Here each element in the list is a separate object containing a link or a pointer to the next. There is no built-in method or function for Linked Lists in Javascript so one has to implement it. An example of a linked list is shown below. 6 | 7 | ``` 8 | ["one", "two", "three", "four"] 9 | ``` 10 | 11 | **Types of Linked Lists** 12 | 13 | There are three different types of linked lists: 14 | 15 | 1. **Singly Linked Lists:** Each node contains only one pointer to the next node. 16 | 2. **Doubly Linked Lists:** There are two pointers at each node, one to the next node and one to the previous node. 17 | 3. **Circular Linked Lists:** A circular linked list forms a loop by having the last node pointing to the first node or any other node before it. 18 | -------------------------------------------------------------------------------- /en/template-literals/linked-list/add.md: -------------------------------------------------------------------------------- 1 | # Add 2 | 3 | The `add` method is created here to add value to a linked list. 4 | 5 | ```javascript 6 | class Node { 7 | constructor(data) { 8 | this.data = data 9 | this.next = null 10 | } 11 | } 12 | 13 | class LinkedList { 14 | constructor(head) { 15 | this.head = head 16 | } 17 | append = (value) => { 18 | const newNode = new Node(value) 19 | let current = this.head 20 | if (!this.head) { 21 | this.head = newNode 22 | return 23 | } 24 | while (current.next) { 25 | current = current.next 26 | } 27 | current.next = newNode 28 | } 29 | } 30 | ``` 31 | -------------------------------------------------------------------------------- /en/template-literals/linked-list/pop.md: -------------------------------------------------------------------------------- 1 | # Pop 2 | 3 | Here, a `pop` method is created to remove a value from the linked list. 4 | 5 | ```javascript 6 | class Node { 7 | constructor(data) { 8 | this.data = data 9 | this.next = null 10 | } 11 | } 12 | 13 | class LinkedList { 14 | constructor(head) { 15 | this.head = head 16 | } 17 | pop = () => { 18 | let current = this.head 19 | while (current.next.next) { 20 | current = current.next 21 | } 22 | current.next = current.next.next 23 | } 24 | } 25 | ``` 26 | -------------------------------------------------------------------------------- /en/template-literals/linked-list/prepend.md: -------------------------------------------------------------------------------- 1 | # Prepend 2 | 3 | Here, a `prepend` method is created to add a value before the first child of the linked list. 4 | 5 | ```javascript 6 | class Node { 7 | constructor(data) { 8 | this.data = data 9 | this.next = null 10 | } 11 | } 12 | 13 | class LinkedList { 14 | constructor(head) { 15 | this.head = head 16 | } 17 | prepend = (value) => { 18 | const newNode = new Node(value) 19 | if (!this.head) { 20 | this.head = newNode 21 | } 22 | else { 23 | newNode.next = this.head 24 | this.head = newNode 25 | } 26 | } 27 | } 28 | ``` 29 | -------------------------------------------------------------------------------- /en/template-literals/linked-list/shift.md: -------------------------------------------------------------------------------- 1 | # Shift 2 | 3 | Here, the `shift` method is created to remove the first element of the Linked List. 4 | 5 | ```javascript 6 | class Node { 7 | constructor(data) { 8 | this.data = data 9 | this.next = null 10 | } 11 | } 12 | 13 | class LinkedList { 14 | constructor(head) { 15 | this.head = head 16 | } 17 | shift = () => { 18 | this.head = this.head.next 19 | } 20 | } 21 | ``` 22 | -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/favicon.ico -------------------------------------------------------------------------------- /js.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/js.png -------------------------------------------------------------------------------- /ne/arrays/pop.md: -------------------------------------------------------------------------------- 1 | # Pop (पप) 2 | 3 | The `pop` method removes the last element from an array and returns that element. This method changes the length of the array. 4 | 5 | 'पप' विधिले एरेबाट अन्तिम तत्व हटाउँदछ र त्यो तत्व फर्काउँछ। यो विधिले सरणीको लम्बाइ परिवर्तन गर्दछ । 6 | 7 | Here's the syntax for using `pop`: 8 | 9 | यहाँ 'पप' प्रयोग गर्नका लागि वाक्यरचना छ: 10 | 11 | ```c 12 | array.pop(); 13 | ``` 14 | 15 | For example: 16 | 17 | उदाहरणको लागी: 18 | 19 | ```javascript 20 | let arr = ["one", "two", "three", "four", "five"]; 21 | arr.pop(); 22 | 23 | console.log(arr); 24 | 25 | // Result: ['one', 'two', 'three', 'four'] 26 | ``` 27 | 28 | You can also use the `pop` method in conjunction with a loop to remove all elements from an array. Here's an example of how you might do this: 29 | 30 | तपाईं एरेबाट सबै तत्वहरू हटाउन लूपको संयोजनमा 'पप' विधि पनि प्रयोग गर्न सक्नुहुन्छ। तपाईं यो कसरी गर्न सक्नुहुन्छ को एक उदाहरण यहाँ छ: 31 | 32 | ```c 33 | while (array.length > 0) { 34 | array.pop(); 35 | } 36 | 37 | console.log(array); // Result: [] 38 | ``` 39 | 40 | {% hint style="warning" %} 41 | 42 | 43 | The `pop` method only works on arrays, and not on other objects that are similar to arrays such as arguments objects or NodeList objects. If you need to pop elements from one of these types of objects, you will need to convert it to an array first using the `Array.prototype.slice()` method. 44 | 45 | `पप` विधिले एरेहरूमा मात्र काम गर्दछ, न कि अन्य वस्तुहरूमा जुन एरेहरू जस्तै तर्क वस्तुहरू वा नोडलिस्ट वस्तुहरूसँग मिल्दोजुल्दो छ। यदि तपाईंलाई यी प्रकारका वस्तुहरूमध्ये कुनै एकबाट तत्वहरू पप गर्न आवश्यक छ भने, तपाईंले यसलाई पहिले `Array.prototype.slice()` विधि प्रयोग गरेर सरणीमा रूपान्तरण गर्न आवश्यक छ। 46 | 47 | {% endhint %} 48 | -------------------------------------------------------------------------------- /ne/arrays/push.md: -------------------------------------------------------------------------------- 1 | # Push (पुश) 2 | 3 | One can push certain items to an array making the last index the newly added item. It changes the length of an array and returns a new length. 4 | 5 | अन्तिम अनुक्रमणिकालाई नयाँ थपिएको वस्तु बनाउने सरणीमा निश्चित वस्तुहरू धकेल्न सकिन्छ। यसले एरेको लम्बाइ परिवर्तन गर्दछ र नयाँ लम्बाइ फर्काउँछ। 6 | 7 | Here's the syntax for using `push`: 8 | 9 | यहाँ 'पुश' प्रयोग गर्नका लागि वाक्यरचना छ: 10 | 11 | ```c 12 | array.push(element1[, ...[, elementN]]); 13 | ``` 14 | 15 | The `element1, ..., elementN` arguments represent the elements to be added to the end of the array. 16 | 17 | `element1, ..., elementN` तर्कहरूले एरेको अन्त्यमा थपिने तत्वहरूको प्रतिनिधित्व गर्दछ। 18 | 19 | For example: 20 | 21 | उदाहरण को लागी: 22 | 23 | ```javascript 24 | let array = [1, 2, 3]; 25 | array.push(4); 26 | 27 | console.log(array); 28 | 29 | // Result: array = [1, 2, 3, 4] 30 | ``` 31 | 32 | You can also use `push` to add elements to the end of an array-like object (such as an arguments object or a NodeList object) by first converting it to an array using the `Array.prototype.slice()` method: 33 | 34 | तपाईँले एरे जस्तो वस्तु (जस्तै तर्क वस्तु वा नोडलिस्ट वस्तु) को अन्त्यमा तत्वहरू थप्न `push` पनि प्रयोग गर्न सक्नुहुन्छ, यसलाई `Array.prototype.slice()` विधि प्रयोग गरेर सरणीमा रूपान्तरण गरेर: 35 | 36 | ```javascript 37 | function printArguments() { 38 | let args = Array.prototype.slice.call(arguments); 39 | args.push('d', 'e', 'f'); 40 | console.log(args); 41 | } 42 | 43 | printArguments('a', 'b', 'c'); // Result: ["a", "b", "c", "d", "e", "f"] 44 | ``` 45 | 46 | Note that the `push` method modifies the original array. It does not create a new array. 47 | 48 | नोट गर्नुहोस् कि `पुश` विधि विधिले मूल एर्रे परिमार्जन गर्दछ। यसले नयाँ एरे सिर्जना गर्दैन। 49 | -------------------------------------------------------------------------------- /ne/arrays/shift.md: -------------------------------------------------------------------------------- 1 | # Shift (सिफ्ट) 2 | 3 | `shift` deletes the first index of that array and moves all indexes to the left. It changes the original array. Here's the syntax for using `shift`: 4 | 5 | `सिफ्ट` ले त्यो एरेको पहिलो अनुक्रमणिका मेट्दछ र सबै अनुक्रमणिकाहरू बायाँतिर सार्दछ। यसले मूल सरणी परिवर्तन गर्दछ। यहाँ 'शिफ्ट' प्रयोग गर्नका लागि वाक्यरचना छ: 6 | 7 | ```c 8 | array.shift(); 9 | ``` 10 | 11 | For example: 12 | उदाहरणका लागि: 13 | ```javascript 14 | let array = [1, 2, 3]; 15 | array.shift(); 16 | 17 | // Result: array = [2,3] 18 | ``` 19 | 20 | You can also use the `shift` method in conjunction with a loop to remove all elements from an array. Here's an example of how you might do this: 21 | 22 | एर्रेबाट सबै तत्वहरू हटाउन तपाईं लूपको संयोजनमा `सिफ्ट` विधि पनि प्रयोग गर्न सक्नुहुन्छ। तपाईं यो कसरी गर्न सक्नुहुन्छ को एक उदाहरण यहाँ छ: 23 | 24 | 25 | ```c 26 | while (array.length > 0) { 27 | array.shift(); 28 | } 29 | 30 | console.log(array); // Result: [] 31 | ``` 32 | 33 | {% hint style="warning" %} 34 | 35 | 36 | The `shift` method only works on arrays, and not on other objects that are similar to arrays such as arguments objects or NodeList objects. If you need to shift elements from one of these types of objects, you will need to convert it to an array first using the `Array.prototype.slice()` method. 37 | 38 | `shift` विधिले एरेहरूमा मात्र काम गर्दछ, न कि अन्य वस्तुहरूमा जुन एरेहरू जस्तै तर्क वस्तुहरू वा नोडलिस्ट वस्तुहरूसँग मिल्दोजुल्दो छ। यदि तपाईंलाई यी प्रकारका वस्तुहरूमध्ये कुनै एकबाट तत्वहरू स्थानान्तरण गर्न आवश्यक छ भने, तपाईंले यसलाई पहिले `Array.prototype.slice()` विधि प्रयोग गरेर एरेमा रूपान्तरण गर्न आवश्यक छ। 39 | {% endhint %} 40 | -------------------------------------------------------------------------------- /ne/arrays/spread.md: -------------------------------------------------------------------------------- 1 | # Spread (फैलने) 2 | 3 | An array or object can be quickly copied into another array or object by using the Spread Operator `(...)`. It allows an iterable such as an array to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected. 4 | 5 | स्प्रेड अपरेटर `(...)` प्रयोग गरेर एरे वा वस्तुलाई अर्को सरणी वा वस्तुमा छिटो प्रतिलिपि गर्न सकिन्छ । यसले पुनरावृत्ति योग्य जस्तै सरणीलाई शून्य वा बढी तर्कहरू (प्रकार्य कलहरूका लागि) वा तत्वहरू (एरे शाब्दिकहरूका लागि) अपेक्षित स्थानहरूमा विस्तार गर्न अनुमति दिन्छ, वा वस्तु अभिव्यक्ति शून्य वा अधिक कुञ्जी-मान जोडीहरू (वस्तु शाब्दिकहरूका लागि) अपेक्षित स्थानहरूमा विस्तार गर्न अनुमति दिन्छ। 6 | 7 | Here are some examples of it: 8 | 9 | यहाँ केहि उदाहरणहरू छन्: 10 | 11 | ```javascript 12 | let arr = [1, 2, 3, 4, 5]; 13 | 14 | console.log(...arr); 15 | // Result: 1 2 3 4 5 16 | 17 | let arr1; 18 | arr1 = [...arr]; //copies the arr into arr1 19 | 20 | console.log(arr1); //Result: [1, 2, 3, 4, 5] 21 | 22 | arr1 = [6,7]; 23 | arr = [...arr,...arr1]; 24 | 25 | console.log(arr); //Result: [1, 2, 3, 4, 5, 6, 7] 26 | 27 | ``` 28 | 29 | {% hint style="warning" %} 30 | 31 | 32 | The spread operator only works in modern browsers that support the feature. If you need to support older browsers, you will need to use a transpiler like Babel to convert the spread operator syntax to equivalent ES5 code. 33 | 34 | स्प्रेड अपरेटरले केवल आधुनिक ब्राउजरहरूमा काम गर्दछ जुन सुविधालाई समर्थन गर्दछ। यदि तपाईंलाई पुरानो ब्राउजरहरू समर्थन गर्न आवश्यक छ भने, तपाईंले स्प्रेड अपरेटर वाक्यविन्यासलाई समकक्ष ईएस 5 कोडमा रूपान्तरण गर्न बाबेल जस्तो ट्रान्सपिलर प्रयोग गर्न आवश्यक हुनेछ। 35 | {% endhint %} 36 | -------------------------------------------------------------------------------- /ne/arrays/unshift.md: -------------------------------------------------------------------------------- 1 | # Unshift (अनशिफ्ट) 2 | 3 | The `unshift` method adds new elements sequentially to the start, or front of the array. It modifies the original array and returns the new length of the array. For example. 4 | 5 | `अनशिफ्ट` विधिले एरेको सुरुमा, वा अगाडि क्रमिक रूपमा नयाँ तत्वहरू थप्दछ। यसले मूल सरणीलाई परिमार्जन गर्दछ र सरणीको नयाँ लम्बाइ फर्काउँछ। उदाहरणका लागि. 6 | 7 | ```javascript 8 | let array = [0, 5, 10]; 9 | array.unshift(-5); // 4 10 | 11 | // RESULT: array = [-5 , 0, 5, 10]; 12 | ``` 13 | 14 | {% hint style="warning" %} 15 | 16 | 17 | The `unshift()` method overwrites the original array. 18 | 19 | `unshift()` विधिले मूल सरणीलाई अधिलेखन गर्दछ। 20 | 21 | {% endhint %} 22 | 23 | The `unshift` method takes one or more arguments, which represent the elements to be added to the beginning of the array. It adds the elements in the order they are provided, so the first element will be the first element of the array. 24 | 25 | `अनशिफ्ट` विधिले एक वा बढी तर्कहरू लिन्छ, जसले सरणीको सुरुमा थपिने तत्वहरूको प्रतिनिधित्व गर्दछ। यसले तत्वहरू प्रदान गरिएको क्रममा थप्दछ, त्यसैले पहिलो तत्व सरणीको पहिलो तत्व हुनेछ। 26 | 27 | Here is an example of using `unshift` to add multiple elements to an array: 28 | 29 | एरेमा बहुविध तत्वहरू थप्न `अनशिफ्ट` प्रयोग गर्ने उदाहरण यहाँ छ: 30 | 31 | ```javascript 32 | const numbers = [1, 2, 3]; 33 | const newLength = numbers.unshift(-1, 0); 34 | console.log(numbers); // [-1, 0, 1, 2, 3] 35 | console.log(newLength); // 5 36 | ``` 37 | -------------------------------------------------------------------------------- /ne/basics/comments.md: -------------------------------------------------------------------------------- 1 | # Comments (टिप्पणीहरू) 2 | 3 | Comments are statements that will not be executed by the interpreter, comments are used to mark annotations for other programmers or small descriptions of what code does, thus making it easier for others to understand what your code does. 4 | 5 | टिप्पणीहरू (comments) बयानहरू हुन् जसले अन्य प्रोग्रामरहरू वा के कोडले के गर्दछ भनेर सहज बनाउँदछन्। 6 | 7 | In JavaScript, comments can be written in 2 different ways: 8 | 9 | जाभास्क्रिप्टमा, टिप्पणीहरू २ तरीकाले लेख्न सकिन्छ: 10 | 11 | * _Single-line comments_: It starts with two forward slashes (`//`) and continue until the end of the line. Anything following the slashes is ignored by the JavaScript interpreter. For example : 12 | 13 | * _एकल रेखा टिप्पणीहरू_: यो दुई फरवार्ड स्ल्याशहरू (`//`) बाट सुरु हुन्छ र रेखाको अन्त्यसम्म जारी रहन्छ। स्ल्याशहरू पछिको कुनै पनि कुरा जाभास्क्रिप्ट इन्तेर्प्रेटरद्वारा उपेक्षा गरिएको छ। उदाहरणका लागि: 14 | 15 | ```javascript 16 | // This is a comment, it will be ignored by the interpreter 17 | let a = "this is a variable defined in a statement"; 18 | ``` 19 | 20 | * Multi-line comments: It starts with a forward slash and an asterisk (`/*`) and end with an asterisk and a forward slash (`*/`). Anything between the opening and closing markers is ignored by the JavaScript interpreter. For example: 21 | 22 | * बहु-रेखा टिप्पणीहरू: अगाडिको स्लेश र तारांकन (`/*`) बाट सुरु हुन्छ र तारांकन र अगाडिको स्लेश (`*/`) सँग समाप्त हुन्छ। उद्घाटन र समापन मार्करहरू बीचको कुनै पनि कुरा जाभास्क्रिप्ट इन्तेर्प्रेटरद्वारा उपेक्षा गरिएको छ। उदाहरणका लागि: 23 | 24 | ```javascript 25 | /* 26 | This is a multi-line comment, 27 | it will be ignored by the interpreter 28 | */ 29 | let a = "this is a variable defined in a statement"; 30 | ``` 31 | -------------------------------------------------------------------------------- /ne/browser-object-model-bom/README.md: -------------------------------------------------------------------------------- 1 | # Browser Object Model (BOM) (ब्राउजर वस्तु मोडेल) 2 | 3 | The browser object model lets us interact with the browser window. `window` object represents the browser's window and is supported by all browsers. 4 | 5 | ब्राउजर वस्तु मोडेलले हामीलाई ब्राउजर सञ्झ्यालसँग अन्तरक्रिया गर्न दिन्छ। `सञ्झ्याल (window)` वस्तुले ब्राउजरको सञ्झ्यालको प्रतिनिधित्व गर्दछ र सबै ब्राउजरहरू द्वारा समर्थित छ। 6 | 7 | Object `window` is the default object for a browser, so we can specify `window` or call directly all the functions. 8 | 9 | वस्तु `सञ्झ्याल` ब्राउजरको लागि पूर्वनिर्धारित वस्तु हो, त्यसैले हामी `सञ्झ्याल` निर्दिष्ट गर्न सक्दछौं वा सबै प्रकार्यहरू सीधै कल गर्न सक्दछौं। 10 | 11 | ```javascript 12 | window.alert("Welcome to Learn JavaScript"); 13 | 14 | alert("Welcome to Learn JavaScript") 15 | ``` 16 | 17 | In a similar fashion, we can call other properties underneath the window object such as history, screen, navigator, location, and so on. 18 | 19 | त्यस्तै तरिकामा, हामी सञ्झ्याल वस्तुको तल अन्य गुणहरू जस्तै इतिहास, स्क्रिन, नेभिगेटर, स्थान, र यतिमा कल गर्न सक्दछौं। 20 | 21 | 22 | -------------------------------------------------------------------------------- /ne/browser-object-model-bom/navigator.md: -------------------------------------------------------------------------------- 1 | # Navigator (नेभिगेटर) 2 | `window.navigator` or `navigator` is a **read-only** property and contains different methods and functions related to the browser. 3 | 4 | `window.navigator` वा `navigator` एक **पढ्न-मात्र** गुण हो र यसले ब्राउजरसँग सम्बन्धित विभिन्न विधिहरू र प्रकार्यहरू समावेश गर्दछ। 5 | 6 | Let's look at a few examples of navigation. 7 | 8 | आउनुहोस् नेभिगेसनका केही उदाहरणहरू हेरौं। 9 | 10 | 1. **navigator.appName**: It gives the name of the browser application 11 | 12 | यसले ब्राउजर एप्लिकेसनको नाम दिन्छ। 13 | 14 | ```javascript 15 | navigator.appName; 16 | // "Netscape" 17 | ``` 18 | 19 | > _**Note:**_ "Netscape" is the application name for IE11, Chrome, Firefox, and Safari. 20 | > _**नोट:**_ "नेटस्केप" आईई ११, क्रोम, फायरफक्स र सफारीको लागि अनुप्रयोग नाम हो। 21 | 22 | 2. **navigator.cookieEnabled**: Returns a boolean value based on the cookie value in the browser. 23 | ब्राउजरमा कुकी मानमा आधारित बुलियन मान फर्काउँछ । 24 | 25 | ```javascript 26 | navigator.cookieEnabled; 27 | //true 28 | ``` 29 | 3. **navigator.platform**: Provides information about the browser operating system. 30 | 31 | ब्राउजर अपरेटिङ सिस्टमको बारेमा जानकारी प्रदान गर्दछ । 32 | 33 | ```javascript 34 | navigator.patform; 35 | "MacIntel" 36 | ``` 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /ne/classes/README.md: -------------------------------------------------------------------------------- 1 | # Classes (वर्ग) 2 | 3 | Classes are templates for creating an object. It encapsulates data with code to work on with data. The keyword `class` is used to create a class. And a specific method called `constructor` is used for creating and initializing an object created with a `class`. An example of car class is shown below. 4 | 5 | वर्गहरू (classes) वस्तु सिर्जना गर्न टेम्प्लेटहरू हुन्। यसले डेटाको साथ काम गर्न कोडको साथ डेटा लाई समाहित गर्दछ। कुञ्जीशब्द 'वर्ग' वर्ग सिर्जना गर्न प्रयोग गरिन्छ। र 'कन्स्ट्रक्टर' नामक एक विशिष्ट विधि 'वर्ग' को साथ सिर्जना गरिएको वस्तु सिर्जना गर्न र सुरु गर्न प्रयोग गरिन्छ। कार वर्गको एक उदाहरण तल देखाइएको छ। 6 | 7 | ```javascript 8 | class Car { 9 | constructor(name, year) { 10 | this.name = name; 11 | this.year = year; 12 | } 13 | age() { 14 | let date = new Date(); 15 | return date.getFullYear() - this.year; 16 | } 17 | } 18 | 19 | let myCar = new Car("Toyota", 2021); 20 | console.log(myCar.age()) // 1 21 | ``` 22 | 23 | {% hint style="info" %} 24 | 25 | 26 | Class must be defined before its usage. 27 | 28 | वर्ग यसको प्रयोग गर्नु अघि परिभाषित गर्नु पर्दछ। 29 | {% endhint %} 30 | 31 | In the class body, methods or constructors are defined and executed in `strict mode`. Syntax not adhering to the strict mode results in error. 32 | 33 | वर्ग शरीरमा, विधिहरू वा कन्स्ट्रक्टरहरू परिभाषित गरिन्छ र `strict mode` मा कार्यान्वयन गरिन्छ। वाक्यविन्यासले कडा मोडको पालना नगर्दा त्रुटि हुन्छ । 34 | -------------------------------------------------------------------------------- /ne/classes/inheritance.md: -------------------------------------------------------------------------------- 1 | # Inheritance (उत्तराधिकार) 2 | 3 | The inheritance is useful for code reusability purposes as it extends existing properties and methods of a class. The `extends` keyword is used to create a class inheritance. 4 | 5 | उत्तराधिकार कोड पुन: प्रयोज्य उद्देश्यहरूको लागि उपयोगी छ किनकि यसले एक वर्गको अवस्थित गुणहरू र विधिहरू विस्तार गर्दछ। वर्ग वंशानुक्रम सिर्जना गर्न `extends` कीवर्ड प्रयोग गरिन्छ। 6 | 7 | ```javascript 8 | class Car { 9 | constructor(brand) { 10 | this.carname = brand; 11 | } 12 | present() { 13 | return 'I have a ' + this.carname; 14 | } 15 | } 16 | 17 | class Model extends Car { 18 | constructor(brand, mod) { 19 | super(brand); 20 | this.model = mod; 21 | } 22 | show() { 23 | return this.present() + ', it is a ' + this.model; 24 | } 25 | } 26 | 27 | let myCar = new Model("Toyota", "Camry"); 28 | console.log(myCar.show()); // I have a Camry, it is a Toyota. 29 | ``` 30 | 31 | {% hint style="info" %} 32 | 33 | 34 | The prototype of the parent class must be an `Object` or `null`. 35 | 36 | अभिभावक वर्गको प्रोटोटाइप 'वस्तु' वा 'शून्य' हुनुपर्दछ। 37 | {% endhint %} 38 | 39 | The `super` method is used inside a constructor and refers to the parent class. With this, one can access the parent class properties and methods. 40 | 41 | 'सुपर' विधि कन्स्ट्रक्टर भित्र प्रयोग गरिन्छ र मूल वर्गलाई बुझाउँछ। यसको साथ, एक अभिभावक वर्ग गुणहरू र विधिहरू पहुँच गर्न सक्दछ। 42 | 43 | -------------------------------------------------------------------------------- /ne/classes/static.md: -------------------------------------------------------------------------------- 1 | # Static (स्थिर) 2 | 3 | The `static` keyword defines the static methods or properties for a class. These methods and properties are called in the class itself. 4 | 5 | 'स्थिर' कीवर्डले वर्गको लागि स्थिर विधिहरू वा गुणहरू परिभाषित गर्दछ। यी विधिहरू र गुणहरू वर्गमा नै भनिन्छ। 6 | 7 | ```javascript 8 | class Car { 9 | constructor(name) { 10 | this.name = name; 11 | } 12 | static hello(x) { 13 | return "Hello " + x.name; 14 | } 15 | } 16 | let myCar = new Car("Toyota"); 17 | 18 | console.log(myCar.hello()); // This will throw an error 19 | console.log(Car.hello(myCar)); 20 | // Result: Hello Toyota 21 | ``` 22 | 23 | {% hint style="info" %} 24 | 25 | 26 | One can access the static method or property of another static method of the same class using `this` keyword. 27 | 28 | `this` कीवर्ड प्रयोग गरेर उही वर्गको अर्को स्थिर विधिको स्थिर विधि वा गुण पहुँच गर्न सक्छ। 29 | {% endhint %} 30 | -------------------------------------------------------------------------------- /ne/conditional/README.md: -------------------------------------------------------------------------------- 1 | # Conditional Logic (सशर्त तर्क) 2 | 3 | A condition is a test for something. Conditions are very important for programming, in several ways: 4 | 5 | अवस्था भनेको कुनै कुराको परीक्षण हो । कार्यक्रमहरूको लागि अवस्थाहरू धेरै तरिकामा धेरै महत्त्वपूर्ण छन्। 6 | 7 | First of all, conditions can be used to ensure that your program works, regardless of what data you throw at it for processing. If you blindly trust data, you’ll get into trouble and your programs will fail. If you test that the thing you want to do is possible and has all the required information in the right format, that won’t happen, and your program will be a lot more stable. Taking such precautions is also known as programming defensively. 8 | 9 | सबै भन्दा पहिले, शर्तहरू तपाईंको कार्यक्रमले काम गर्दछ भनेर सुनिश्चित गर्न प्रयोग गर्न सकिन्छ, चाहे तपाईले प्रक्रियाको लागि कुन डेटा फ्याँक्नुहुन्छ। यदि तपाईं अन्धाधुन्ध डेटामा विश्वास गर्नुहुन्छ भने, तपाईं समस्यामा पर्नुहुनेछ र तपाईंको कार्यक्रमहरू असफल हुनेछन्। यदि तपाईं परीक्षण गर्नुहुन्छ कि तपाईले गर्न चाहानुभएको कुरा सम्भव छ र सही ढाँचामा सबै आवश्यक जानकारी छ भने, त्यो हुनेछैन, र तपाईंको कार्यक्रम धेरै स्थिर हुनेछ। यस्तो सावधानी अपनाउनुलाई रक्षात्मक रूपमा प्रोग्रामिंग पनि भनिन्छ। 10 | 11 | The other thing conditions can do for you is allow for branching. You might have encountered branching diagrams before, for example when filling out a form. Basically, this refers to executing different “branches” (parts) of code, depending on if the condition is met or not. 12 | 13 | तपाईंको लागि अवस्थाहरूले गर्न सक्ने अर्को कुरा शाखाहरूको लागि अनुमति दिनु हो। उदाहरणका लागि, फारम भर्दा तपाईंले पहिले नै शाखाचित्रहरू सामना गर्नुभएको हुन सक्छ। मूलतः, यसले कोडको विभिन्न "शाखाहरू" (भागहरू) कार्यान्वयन गर्न बुझाउँछ, यदि शर्त पूरा भएको छ वा छैन भन्ने मा निर्भर गर्दछ। 14 | 15 | In this chapter, we'll learn the basis of conditional logic in Javascript. 16 | 17 | यस अध्यायमा, हामी जाभास्क्रिप्टमा सशर्त तर्कको आधार सिक्नेछौं। 18 | -------------------------------------------------------------------------------- /ne/conditional/concatenate.md: -------------------------------------------------------------------------------- 1 | # Concatenate (संयोजन) 2 | 3 | Furthermore. you can concatenate different conditions with "`or`" or “`and`” statements, to test whether either statement is true, or both are true, respectively. 4 | 5 | यसबाहेक, तपाईं `"वा"` वा `"र"` कथनहरूसँग विभिन्न अवस्थाहरू संयोजन गर्न सक्नुहुन्छ, क्रमशः कथन सत्य छ कि छैन, वा दुवै सत्य छन् कि छैन भनेर परीक्षण गर्न। 6 | 7 | In JavaScript “or” is written as `||` and “and” is written as `&&`. 8 | 9 | जाभास्क्रिप्टमा "वा" लाई `||` र " र " लाई `&&` को रूपमा लेखिएको छ। 10 | 11 | Say you want to test if the value of x is between 10 and 20—you could do that with a condition stating: 12 | 13 | एक्सको मान १० र २० को बीचमा छ कि छैन भनेर परीक्षण गर्न चाहनुहुन्छ — तपाईँले एउटा शर्तका साथ त्यसो गर्न सक्नुहुन्छ: 14 | 15 | ```javascript 16 | if (x > 10 && x < 20) { 17 | ... 18 | } 19 | ``` 20 | 21 | If you want to make sure that country is either “England” or “Germany” you use: 22 | 23 | यदि तपाईं यो सुनिश्चित गर्न चाहनुहुन्छ कि देश "इङ्गल्याण्ड" वा "जर्मनी" हो भने तपाईंले प्रयोग गर्नुहुन्छ: 24 | 25 | ```javascript 26 | if (country === "England" || country === "Germany") { 27 | ... 28 | } 29 | ``` 30 | 31 | **Note**: Just like operations on numbers, Conditions can be grouped using parenthesis, ex: `if ( (name === "John" || name === "Jennifer") && country === "France")`. 32 | 33 | **नोट**: संख्याहरूमा सञ्चालनहरू जस्तै, अवस्थाहरू कोष्ठक प्रयोग गरेर समूहीकृत गर्न सकिन्छ, उदाहरण: `यदि ( नाम === "जोन" || नाम === "जेनिफर") && देश === "फ्रान्स")`। 34 | -------------------------------------------------------------------------------- /ne/conditional/if.md: -------------------------------------------------------------------------------- 1 | # If (यदि) 2 | 3 | The easiest condition is an if statement and its syntax is `if(condition){ do this … }`. The condition has to be true for the code inside the curly braces to be executed. You can for example test a string and set the value of another string dependent on its value: 4 | 5 | सबै भन्दा सजिलो शर्त एक यदि कथन हो र यसको वाक्य रचना `if (शर्त){ यो गर्नुहोस् ... }`. घुँघराले ब्रेसेस भित्रको कोड कार्यान्वयन गर्नका लागि शर्त सही हुनुपर्दछ। उदाहरणका लागि तपाईँले स्ट्रिङ परीक्षण गर्न सक्नुहुन्छ र यसको मानमा निर्भर अर्को स्ट्रिङको मान सेट गर्न सक्नुहुन्छ। 6 | 7 | 8 | 9 | ```javascript 10 | let country = "France"; 11 | let weather; 12 | let food; 13 | let currency; 14 | 15 | if (country === "England") { 16 | weather = "horrible"; 17 | food = "filling"; 18 | currency = "pound sterling"; 19 | } 20 | 21 | if (country === "France") { 22 | weather = "nice"; 23 | food = "stunning, but hardly ever vegetarian"; 24 | currency = "funny, small and colourful"; 25 | } 26 | 27 | if (country === "Germany") { 28 | weather = "average"; 29 | food = "wurst thing ever"; 30 | currency = "funny, small and colourful"; 31 | } 32 | 33 | let message = 34 | "this is " + 35 | country + 36 | ", the weather is " + 37 | weather + 38 | ", the food is " + 39 | food + 40 | " and the " + 41 | "currency is " + 42 | currency; 43 | 44 | console.log(message); 45 | // 'this is France, the weather is nice, the food is stunning, but hardly ever vegetarian and the currency is funny, small and colourful' 46 | ``` 47 | 48 | {% hint style="info" %} 49 | 50 | 51 | Conditions can also be nested. 52 | 53 | अवस्थाहरू पनि नेस्टेड गर्न सकिन्छ। 54 | {% endhint %} 55 | -------------------------------------------------------------------------------- /ne/error-handling/README.md: -------------------------------------------------------------------------------- 1 | # Error Handling 2 | 3 | -------------------------------------------------------------------------------- /ne/exercises/README.md: -------------------------------------------------------------------------------- 1 | # Exercises 2 | 3 | -------------------------------------------------------------------------------- /ne/exercises/concatenation.md: -------------------------------------------------------------------------------- 1 | # Concatenation (कन्काटेनेसन) 2 | 3 | In any programming language, string concatenation simply means appending one or more strings to another string. For example, when strings "_World_" and "_Good Afternoon_" are concatenated with string "_Hello_", they form the string "_Hello World, Good Afternoon_". We can concatenate a string in several ways in JavaScript. 4 | 5 | कुनै पनि प्रोग्रामिंग भाषामा, स्ट्रिङ संयोजनको अर्थ केवल एक वा बढी स्ट्रिङहरू अर्को स्ट्रिङमा जोड्नु हो। उदाहरणका लागि, जब स्ट्रिङहरू "_World_" र "_Good Afternoon_" स्ट्रिङ "_Hello_" सँग संयोजन गरिन्छ, तिनीहरूले स्ट्रिङ "_Hello World, Good Afternoon_" बनाउँदछन्। हामी जाभास्क्रिप्टमा धेरै तरिकामा स्ट्रिङ संयोजन गर्न सक्दछौं। 6 | 7 | 8 | ### Example: 9 | 10 | ```javascript 11 | const icon = '👋'; 12 | 13 | // using template Strings 14 | `hi ${icon}`; 15 | 16 | // using join() Method 17 | ['hi', icon].join(' '); 18 | 19 | // using concat() Method 20 | ''.concat('hi ', icon); 21 | 22 | // using + operator 23 | 'hi ' + icon; 24 | 25 | // RESULT 26 | // hi 👋 27 | ``` 28 | 29 | ### 📝 Task: 30 | 31 | * [ ] Write a program to set the values for `str1`and `str2` so the code prints '_Hello World_' to the console. 32 | 33 | * [ ]`str1` र `str2` का लागि मानहरू सेट गर्न कार्यक्रम लेख्नुहोस् ताकि कोडले कन्सोलमा '_Hello World_' मुद्रण गर्दछ। 34 | 35 | ### 💡 Hints: 36 | 37 | * Visit the [concatenation](../strings/concat.md) chapter of strings for more info about string concatenation. 38 | 39 | * स्ट्रिङ संयोजनको बारेमा थप जानकारीको लागि [स्ट्रिङको संयोजन](../strings/concat.md) अध्यायमा जानुहोस्। 40 | -------------------------------------------------------------------------------- /ne/exercises/conditional-statements.md: -------------------------------------------------------------------------------- 1 | # Conditional Statements (सशर्त तर्क) 2 | 3 | Conditional logic is vital in programming as it makes sure that the program works regardless of what data you throw in and also allows branching. This exercise is about the implementation of various conditional logic in real-life problems. 4 | 5 | सशर्त तर्क प्रोग्रामिंगमा महत्त्वपूर्ण छ किनकि यसले यो सुनिश्चित गर्दछ कि प्रोग्रामले काम गर्दछ चाहे तपाईले कुन डेटा फ्याँक्नुहुन्छ र शाखाहरू पनि अनुमति दिनुहुन्छ। यो अभ्यास वास्तविक जीवन समस्याहरूमा विभिन्न सशर्त तर्कको कार्यान्वयनको बारेमा हो। 6 | 7 | ### 📝 Task: 8 | 9 | * [ ] Write a program to create a prompt "_How many km is left to go?_" and based on the user and the following conditions, print the results in the `console`. 10 | 11 | * [ ] `कति किलोमिटर जान बाँकी छ?` प्रोम्प्ट सिर्जना गर्न कार्यक्रम लेख्नुहोस् र प्रयोगकर्ता र निम्न सर्तहरूको आधारमा, कन्सोलमा परिणामहरू मुद्रण गर्नुहोस्। 12 | * If there are more than 100 km left to go, print: `"You still have a bit of driving left to go"`. 13 | * यदि त्यहाँ जान 100 किलोमिटर भन्दा बढी बाँकी छ भने, मुद्रण गर्नुहोस्: `तपाईंसँग अझै पनि ड्राइभिंगको एक बिट बाँकी छ`। 14 | * If there are more than 50 km, but less or equal to 100 km, print: `"I'll be there in 5 minutes"`. 15 | * यदि त्यहाँ 50 किलोमिटर भन्दा बढी छ, तर 100 किलोमिटर भन्दा कम वा बराबर छ भने, मुद्रण गर्नुहोस्: `म 5 मिनेटमा त्यहाँ हुनेछु`। 16 | * If there are less than or equal to 50 km, print: `"I'm parking. I'll see you right now"`. 17 | * यदि त्यहाँ 50 किलोमिटर भन्दा कम वा बराबर छ भने, मुद्रण गर्नुहोस्: `म पार्किंग गर्दैछु। म तपाईंलाई अहिले भेट्छु।` 18 | 19 | ### 💡 Hints: 20 | 21 | * Visit the [conditional logic](../conditional/) chapter to understand how to use conditional logic and conditional statements. 22 | 23 | * सशर्त तर्क र सशर्त कथनहरू कसरी प्रयोग गर्ने भनेर बुझ्न सशर्त [तर्क](../conditional/) अध्यायमा जानुहोस्। 24 | -------------------------------------------------------------------------------- /ne/exercises/console.md: -------------------------------------------------------------------------------- 1 | # Console (कन्सोल) 2 | 3 | In JavaScript, we use `console.log()` to write a message (the content of a variable, a given string, etc.) in `console`. It is mainly used for debugging purposes, ideally to leave a trace of the content of variables during the execution of a program. 4 | 5 | जाभास्क्रिप्टमा, हामी कन्सोलमा सन्देश (चरको सामग्री, दिइएको स्ट्रिङ, आदि) लेख्न `console.log()` प्रयोग गर्दछौं। यो मुख्यतया डिबगिंग उद्देश्यहरूको लागि प्रयोग गरिन्छ, आदर्श रूपमा कार्यक्रमको कार्यान्वयनको क्रममा चरहरूको सामग्रीको ट्रेस छोड्नको लागि। 6 | 7 | ### Example: 8 | 9 | ```javascript 10 | console.log("Welcome to Learn JavaScript Beginners Edition"); 11 | let age = 30; 12 | console.log(age); 13 | ``` 14 | 15 | ### 📝 Tasks: 16 | 17 | * [ ] Write a program to print `Hello World` on the console. Feel free to try other things as well! 18 | 19 | * [ ] कन्सोलमा 'हेलो वर्ल्ड' प्रिन्ट गर्न कार्यक्रम लेख्नुहोस् । अन्य कुराहरू पनि प्रयास गर्न स्वतन्त्र महसुस गर्नुहोस्! 20 | * [ ] Write a program to print variables to the `console`. 21 | 22 | * [ ] 'कन्सोल' मा चल मुद्रण गर्न कार्यक्रम लेख्नुहोस् । 23 | 1. Declare a variable `animal` and assign the dragon value to it. 24 | 1. एक चर `animal` घोषणा गर्नुहोस् र यसलाई ड्रैगन मान निर्दिष्ट गर्नुहोस्। 25 | 2. Print the `animal` variable to the `console`. 26 | 2. `कन्सोल` मा `animal` चर मुद्रण गर्नुहोस् । 27 | 28 | ### 💡 Hints: 29 | 30 | * Visit the [variabl](../basics/variables.md)[e](../basics/variables.md) chapter to understand more about variables. 31 | * चरहरूको बारेमा थप बुझ्न [चर](../basics/variables.md) अध्यायमा जानुहोस्। 32 | -------------------------------------------------------------------------------- /ne/exercises/constants.md: -------------------------------------------------------------------------------- 1 | # Constants (स्थिरहरू) 2 | 3 | Constants were introduced in ES6(2015), and use a `const` keyword. Variables that are declared with `const` cannot be reassigned or redeclared. 4 | 5 | स्थिरहरू ईएस ६ (2015) मा प्रस्तुत गरिएको थियो, र `कन्स्ट` कीवर्ड प्रयोग गर्दछ। `कन्स्ट` सँग घोषणा गरिएका भेरिएबलहरू पुन: असाइन गर्न वा पुन: परिभाषित गर्न सकिँदैन। 6 | 7 | ### Example: 8 | 9 | ```javascript 10 | const VERSION = '1.2'; 11 | ``` 12 | 13 | ### 📝 Task: 14 | 15 | * [ ] Run the program mentioned below and fix the error that you see in the console. Make sure that the code result is `0.9` when it is fixed in the console. 16 | 17 | * [ ] तल उल्लिखित कार्यक्रम चलाउनुहोस् र तपाईँले कन्सोलमा देख्नुभएको त्रुटि ठीक पार्नुहोस् । निश्चित गर्नुहोस् कि कोड परिणाम `०.९` हो जब यो कन्सोलमा फिक्स गरिएको छ। 18 | 19 | ```javascript 20 | const VERSION = '0.7'; 21 | VERSION = '0.9'; 22 | console.log(VERSION); 23 | ``` 24 | 25 | ### 💡 Hints: 26 | 27 | * Visit the [Variables](../basics/variables.md) chapter for more info about const and also look for "_TypeError assignment to constant variable_" in search engines to learn a fix. 28 | 29 | * कन्स्टको बारेमा थप जानकारीको लागि [भेरिएबल्स](../basics/variables.md) अध्यायमा जानुहोस् र फिक्स सिक्नका लागि खोजी इन्जिनमा "स्थिर चरमा टाइपइरर असाइनमेन्ट" पनि हेर्नुहोस्। 30 | -------------------------------------------------------------------------------- /ne/exercises/fizzbuzz-problem.md: -------------------------------------------------------------------------------- 1 | # FizzBuzz Problem (फिजबज समस्या) 2 | 3 | The _FizzBuzz_ problem is one of the commonly asked questions, here one has to print _Fizz_ and _Buzz_ upon some conditions. 4 | 5 | फिजबज समस्या सामान्यतया सोधिने प्रश्नहरू मध्ये एक हो, यहाँ केहि शर्तहरूमा फिज र बज प्रिन्ट गर्नु पर्दछ। 6 | 7 | ### 📝 Tasks: 8 | 9 | * [ ] Write a program to print all the numbers between 1 to 100 in such a way that the following conditions are met. 10 | 11 | * [ ] १ देखि १०० को बीचमा सबै नम्बरहरू यसरी मुद्रण गर्न एक कार्यक्रम लेख्नुहोस् कि निम्न सर्तहरू पूरा हुन्छन्। 12 | * For multiples of 3, instead of the number, print `Fizz`. 13 | * ३ को गुणकको लागि, नम्बरको सट्टा, `फिज` मुद्रण गर्नुहोस्। 14 | * For multiples of 5, print `Buzz`. 15 | * ५ को गुणकको लागि, `बज` मुद्रण गर्नुहोस्। 16 | * ३ र ५ दुवैको गुणक भएका नम्बरका लागि `फिजबज` प्रिन्ट गर्नुहोस्। 17 | 18 | 19 | ```javascript 20 | / 21 | 1 22 | 2 23 | Fizz 24 | 4 25 | Buzz 26 | Fizz 27 | 7 28 | 8 29 | Fizz 30 | Buzz 31 | 11 32 | Fizz 33 | 13 34 | 14 35 | FizzBuzz 36 | 16 37 | .... 38 | .... 39 | 98 40 | Fizz 41 | Buzz 42 | / 43 | ``` 44 | 45 | ### 💡 Hints: 46 | 47 | * Visit the [loops](../loops/) chapter to understand how the loop works. 48 | 49 | * लूपले कसरी काम गर्दछ भनेर बुझ्न [लूप](../loops/) अध्यायमा जानुहोस्। 50 | -------------------------------------------------------------------------------- /ne/exercises/functions.md: -------------------------------------------------------------------------------- 1 | # Functions (प्रकार्य) 2 | 3 | A function is a block of code designed to perform a specific task and executed when "something" invokes it. More info about functions can be found in the [functions](../functions/) chapter. 4 | 5 | प्रकार्य एक विशिष्ट कार्य प्रदर्शन गर्न डिजाइन गरिएको कोडको ब्लक हो र "केहि" ले यसलाई आह्वान गर्दा निष्पादित हुन्छ। प्रकार्यहरूको बारेमा थप जानकारी [प्रकार्यहरू](../functions/) अध्यायमा फेला पार्न सकिन्छ। 6 | 7 | 8 | ### 📝 Task: 9 | 10 | * [ ] Write a program to create a function named `isOdd`that passes a number `45345` as an argument and determines whether the number is odd or not. 11 | 12 | * [ ] ४५३४५ नम्बरलाई तर्कको रूपमा पास गर्ने र सङ्ख्या विषम छ वा छैन भनेर निर्धारण गर्ने `isOdd` नामको प्रकार्य सिर्जना गर्न कार्यक्रम लेख्नुहोस् । 13 | * [ ] Call this function to get the result. The result should be in a boolean format and should return `true` in `console`. 14 | * [ ] परिणाम प्राप्त गर्न यो प्रकार्यलाई कल गर्नुहोस् । परिणाम बुलियन ढाँचामा हुनुपर्दछ र कन्सोलमा सही फर्कनुपर्छ। 15 | 16 | ### 💡 Hints: 17 | 18 | * Visit the [functions](../functions/) chapter to understand functions and how to create them. 19 | 20 | * प्रकार्यहरू बुझ्न र तिनीहरूलाई कसरी सिर्जना गर्ने भनेर [प्रकार्यहरू](../functions/) अध्यायमा जानुहोस्। 21 | -------------------------------------------------------------------------------- /ne/exercises/get-the-titles.md: -------------------------------------------------------------------------------- 1 | # Get the Titles! (टाइल प्राप्त गर्नुहोस्) 2 | 3 | 4 | The _Get the Tiles!_ problem is an interesting problem where we have to get the title from a list of books. This is a good exercise for the implementation of arrays and objects. 5 | 6 | _टाइल प्राप्त गर्नुहोस्!_ समस्या एक रोचक समस्या हो जहाँ हामीले पुस्तकहरूको सूचीबाट शीर्षक प्राप्त गर्नुपर्दछ। यो एरे र वस्तुहरूको कार्यान्वयनको लागि एक राम्रो अभ्यास हो। 7 | 8 | ### 📝 Tasks: 9 | 10 | Given an array of objects that represent books with an author. 11 | 12 | एक लेखकसंग पुस्तकहरू प्रतिनिधित्व गर्ने वस्तुहरूको एक एर्रे दिइएको छ। 13 | 14 | ```javascript 15 | const books = [ 16 | { 17 | title: "Eloquent JavaScript, Third Edition", 18 | author: "Marijn Haverbeke" 19 | }, 20 | { 21 | title: "Practical Modern JavaScript", 22 | author: "Nicolás Bevacqua" 23 | } 24 | ] 25 | ``` 26 | 27 | * [ ] Write a program to create a function `getTheTitles` that takes the array and returns the array of title and print its value in the `console`. 28 | 29 | * [ ] प्रकार्य `getTheTitles` सिर्जना गर्न कार्यक्रम लेख्नुहोस् जसले एरे लिन्छ र शीर्षकको सरणी फर्काउँछ र `कन्सोल` मा यसको मान मुद्रण गर्दछ। 30 | 31 | ### 💡 Hints: 32 | 33 | * Visit the [arrays](../arrays/) and [objects](../objects/) chapter to understand how the array and object work. 34 | 35 | * एरे र वस्तुले कसरी काम गर्दछ भनेर बुझ्न [एरे](../arrays/) र [वस्तुहरू](../objects/) अध्यायमा जानुहोस्। 36 | 37 | -------------------------------------------------------------------------------- /ne/exercises/multiplication.md: -------------------------------------------------------------------------------- 1 | # Multiplication (गुणन) 2 | 3 | In JavaScript, we can perform the multiplication of two numbers by using the asterisk `(*)` arithmetic operators. 4 | 5 | जाभास्क्रिप्टमा, हामी तारांकन `(*)` अंकगणितीय अपरेटरहरू प्रयोग गरेर दुई संख्याहरूको गुणन प्रदर्शन गर्न सक्दछौं। 6 | 7 | ### Example: 8 | 9 | ```javascript 10 | let resultingValue = 3 * 2; 11 | ``` 12 | 13 | Here, we stored the product of `3 * 2` into a `resultingValue` variable. 14 | 15 | यहाँ, हामीले `3 * 2` को उत्पादनलाई `resultingValue` चरमा भण्डारण गर्यौं। 16 | ### 📝 Tasks: 17 | 18 | * [ ] Write a program to store the product of `23` times `41` and print its value. 19 | 20 | * [ ] '23' पटक '41' को उत्पादन भण्डारण गर्न र यसको मान मुद्रण गर्न एक कार्यक्रम लेख्नुहोस्। 21 | 22 | ### 💡 Hints: 23 | 24 | * Visit the [Basic Operators](../numbers/operators.md) chapter to understand the mathematical operations. 25 | 26 | * गणितीय सञ्चालनहरू बुझ्न [आधारभूत अपरेटरहरू](../numbers/operators.md) अध्यायमा जानुहोस्। 27 | -------------------------------------------------------------------------------- /ne/exercises/user-input-variables.md: -------------------------------------------------------------------------------- 1 | # User Input Variables (प्रयोगकर्ताहरूबाट इनपुट) 2 | 3 | In JavaScript, we can take input from users and use it as a variable. One doesn't need to know their value to work with them. 4 | 5 | जाभास्क्रिप्टमा, हामी प्रयोगकर्ताहरूबाट इनपुट लिन सक्छौं र यसलाई चरको रूपमा प्रयोग गर्न सक्दछौं। तिनीहरूसँग काम गर्न उनीहरूको मूल्य जान्न आवश्यक छैन। 6 | 7 | ### 📝 Tasks: 8 | 9 | * [ ] Write a program to take input from a user and add `10` to it, and print its result. 10 | 11 | * [ ] प्रयोगकर्ताबाट आगत लिन र त्यसमा `१०` थप्न कार्यक्रम लेख्नुहोस्, र यसको परिणाम मुद्रण गर्नुहोस् । 12 | 13 | ### 💡 Hints: 14 | 15 | * The content of a variable is determined by the user's inputs. The `prompt()` method saves the input value as a string. 16 | 17 | * चरको सामग्री प्रयोगकर्ताको इनपुटद्वारा निर्धारित गरिन्छ। `prompt()` विधिले स्ट्रिङको रूपमा आगत मान बचत गर्दछ । 18 | * You will need to make sure that the string value is converted into an integer for calculations. 19 | 20 | * तपाईँले स्ट्रिङ मान गणनाका लागि पूर्णांकमा रूपान्तरण भएको सुनिश्चित गर्न आवश्यक छ । 21 | * Visit the [Basic Operators](../numbers/operators.md) chapter for the type conversion of `string` to `int`. 22 | 23 | * स्ट्रिङलाई इन्टमा रूपान्तरण गर्ने प्रकारका लागि [आधारभूत अपरेटर](../numbers/operators.md) अध्याय मा जानुहोस् । 24 | -------------------------------------------------------------------------------- /ne/loops/README.md: -------------------------------------------------------------------------------- 1 | # Loops (लूप) 2 | 3 | Loops are repetitive conditions where one variable in the loop changes. Loops are handy, if you want to run the same code over and over again, each time with a different value. 4 | 5 | लूपहरू दोहोरिने अवस्थाहरू हुन् जहाँ लूपमा एक चर परिवर्तन हुन्छ। लुपहरू सजिलो छन्, यदि तपाईं एउटै कोड पटक-पटक चलाउन चाहनुहुन्छ भने, प्रत्येक पटक फरक मानको साथ। 6 | 7 | Instead of writing: 8 | 9 | लेख्नुको सट्टा: 10 | 11 | ```javascript 12 | doThing(cars[0]); 13 | doThing(cars[1]); 14 | doThing(cars[2]); 15 | doThing(cars[3]); 16 | doThing(cars[4]); 17 | ``` 18 | 19 | You can write: 20 | 21 | तपाईं लेख्न सक्नुहुन्छ: 22 | 23 | ```javascript 24 | for (var i = 0; i < cars.length; i++) { 25 | doThing(cars[i]); 26 | } 27 | ``` 28 | 29 | -------------------------------------------------------------------------------- /ne/loops/dowhile.md: -------------------------------------------------------------------------------- 1 | # Do...While (डु ... वहाइल) 2 | 3 | The do...while statement creates a loop that executes a specified statement until the test condition evaluates to be false. The condition is evaluated after executing the statement. The syntax for do... while is 4 | 5 | डु ... वहाइल कथनले लूप सिर्जना गर्दछ । यसले तबसम्म निर्दिष्ट कथन कार्यान्वयन गर्दछ जबसम्म परीक्षण अवस्था गलत हुन को लागी मूल्यांकन गर्दैन। बयान कार्यान्वयन पछि अवस्था मूल्यांकन गरिन्छ। 6 | 7 | 8 | ```javascript 9 | do { 10 | // statement 11 | } while (expression); 12 | ``` 13 | 14 | Lets for example see how to print numbers less than 10 using `do...while` loop: 15 | 16 | उदाहरणका लागि हेरौं कसरी १० भन्दा कम नम्बरहरू मुद्रण गर्ने । 17 | 18 | ```javascript 19 | var i = 0; 20 | do { 21 | document.write(i + " "); 22 | i++; // incrementing i by 1 23 | } while (i < 10); 24 | ``` 25 | 26 | > _**Note**_: `i = i + 1` can be written `i++`. 27 | 28 | -------------------------------------------------------------------------------- /ne/loops/for.md: -------------------------------------------------------------------------------- 1 | # For (फर) 2 | 3 | The easiest form of a loop is the for statement. This one has a syntax that is similar to an if statement, but with more options: 4 | 5 | लुपको सब भन्दा सजिलो रूप फर हो। 6 | 7 | ```javascript 8 | for (condition; end condition; change) { 9 | // do it, do it now 10 | } 11 | ``` 12 | 13 | Let's see how to execute the same code ten-times using a `for` loop: 14 | 15 | हामीले `फर` लूप प्रयोग गरेर दस पटक एउटै कोड कसरी कार्यान्वयन गर्छौ, हेरौं । 16 | 17 | ```javascript 18 | for (let i = 0; i < 10; i = i + 1) { 19 | // do this code ten-times 20 | } 21 | ``` 22 | 23 | > _**Note**_: `i = i + 1` can be written `i++`. 24 | 25 | > _**नोट**_: `i = i + 1` लागि यसरि लेख्न सकिन्छ `i++`। 26 | 27 | To loop through the properties of an object or an array `for in` loop can also be used. 28 | 29 | एक वस्तु वा एरे `फर इन` लूपको गुणहरू मार्फत लूप गर्न पनि प्रयोग गर्न सकिन्छ। 30 | 31 | ```javascript 32 | for (key in object) { 33 | // code block to be executed 34 | } 35 | ``` 36 | 37 | Examples of `for in` loop for an object and array is shown below: 38 | 39 | वस्तु र एरेका लागि फर इन` लूपका उदाहरणहरू तल देखाइएको छ। 40 | 41 | ```javascript 42 | const person = {fname:"John", lname:"Doe", age:25}; 43 | let info = ""; 44 | for (let x in person) { 45 | info += person[x]; 46 | } 47 | 48 | // Result: info = "JohnDoe25" 49 | 50 | const numbers = [45, 4, 9, 16, 25]; 51 | let txt = ""; 52 | for (let x in numbers) { 53 | txt += numbers[x]; 54 | } 55 | 56 | // Result: txt = '45491625' 57 | ``` 58 | 59 | The value of iterable objects such as `Arrays`, `Strings`, `Maps`, `NodeLists` can be looped using `for of` statement. 60 | 61 | पुनरावृत्ति योग्य वस्तुहरूको मान जस्तै `एरे`, `स्ट्रिङ्स`, `म्याप्स`, `नोडलिस्ट्स` को लागि कथन प्रयोग गरेर लुप गर्न सकिन्छ। 62 | 63 | ```javascript 64 | let language = "JavaScript"; 65 | let text = ""; 66 | for (let x of language) { 67 | text += x; 68 | } 69 | ``` 70 | -------------------------------------------------------------------------------- /ne/loops/while.md: -------------------------------------------------------------------------------- 1 | # While (वहाइल) 2 | 3 | While Loops repetitively execute a block of code as long as a specified condition is true. 4 | 5 | वहाइल लूपहरूले निर्दिष्ट गरिएको अवस्था सत्य भएसम्म कोडको ब्लक पुनरावृत्ति रूपमा कार्यान्वयन गर्दछ। 6 | 7 | ```javascript 8 | while (condition) { 9 | // do it as long as condition is true 10 | } 11 | ``` 12 | 13 | For example, the loop in this example will repetitively execute its block of code as long as the variable i is less than 5: 14 | 15 | उदाहरणका लागि, वहाइल लूपले यसको कोडको ब्लकलाई पुनरावृत्ति रूपमा कार्यान्वयन गर्नेछ जबसम्म चर म ५ भन्दा कम छ: 16 | 17 | ```javascript 18 | var i = 0, 19 | x = ""; 20 | while (i < 5) { 21 | x = x + "The number is " + i; 22 | i++; 23 | } 24 | ``` 25 | 26 | {% hint style="warning" %} 27 | 28 | 29 | Be careful to avoid infinite looping if the condition is always true! 30 | 31 | यदि अवस्था सधैं साँचो छ भने अनन्त लूपिङबाट जोगिन होसियार हुनुहोस्! 32 | {% endhint %} 33 | -------------------------------------------------------------------------------- /ne/miscellaneous/README.md: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | 3 | -------------------------------------------------------------------------------- /ne/miscellaneous/hoisting.md: -------------------------------------------------------------------------------- 1 | # Hoisting (होइस्टिंग) 2 | 3 | Hosting is a default behavior in JavaScript of moving declarations at the top. While executing a code, it creates a global execution context: creation and execution. In the creation phase, JavaScript moves the variable and function declaration to the top of the page, which is known as hoisting. 4 | 5 | होस्टिङ जाभास्क्रिप्टमा पूर्वनिर्धारित व्यवहार हो जुन शीर्षमा घोषणाहरू सार्ने छ। एक कोड कार्यान्वयन गर्दा, यसले विश्वव्यापी कार्यान्वयन सन्दर्भ सिर्जना गर्दछ: सिर्जना र कार्यान्वयन। सिर्जना चरणमा, जाभास्क्रिप्टले चर र प्रकार्य घोषणालाई पृष्ठको शीर्षमा सार्दछ, जुन उत्थानको रूपमा चिनिन्छ। 6 | 7 | ```javascript 8 | // variable hoisting 9 | console.log(counter); 10 | let counter = 1; // throws ReferenceError: Cannot access 'counter' before initialization 11 | ``` 12 | 13 | Although the `counter` is present in the heap memory but hasn't been initialized so, it throws an error. This happens because of hoisting, the `counter` variable is hoisted here. 14 | 15 | यद्यपि 'काउन्टर' ढेर मेमोरीमा अवस्थित छ तर सुरु गरिएको छैन, यसले त्रुटि फ्याँक्छ। यो फहराउने कारण हुन्छ, 'काउन्टर' चर यहाँ फहराइन्छ।; 16 | 17 |
// function hoisting
18 | const x = 20,
19 |     y = 10;
20 | 
21 | let result = add(x,y); // ❌ Uncaught ReferenceError: add is not defined
22 | console.log(result);
23 | 
24 | let add = (x, y) => x + y;
25 | 
26 | 27 | Here, the `add` function is hoisted and initialized with `undefined` in heap memory in the creation phase of the global execution context. Thus, throwing an error. 28 | 29 | यहाँ, `add` प्रकार्य निस्कियो र विस्तृत जानकारीको रूपमा` अपरिभाइनको साथ आरम्भ गरिएको छ। यसैले, त्रुटि फ्याँक्दै। 30 | 31 | 32 | -------------------------------------------------------------------------------- /ne/miscellaneous/template-literals.md: -------------------------------------------------------------------------------- 1 | # Template Literals (टेम्प्लेट शाब्दिक) 2 | 3 | Template literals are literals delaminated with backtick `(``)` and are used in variable and expression interpolation into strings. 4 | 5 | टेम्प्लेट शाब्दिक हरू ब्याकटिक `(``)` को साथ डिलेमिनेटेड शाब्दिकहरू हुन् र स्ट्रिंगहरूमा चर र अभिव्यक्ति प्रक्षेपमा प्रयोग गरिन्छ। 6 | 7 | ```javascript 8 | let text = `Hello World!`; 9 | // template literals with both single and double code inside a single string 10 | let text = `He's often called "Johnny"`; 11 | // template literals with multiline strings 12 | let text = 13 | `The quick 14 | brown fox 15 | jumps over 16 | the lazy dog`; 17 | 18 | // template literals with variable interpolation 19 | const firstName = "John"; 20 | const lastName = "Doe"; 21 | 22 | const welcomeText = `Welcome ${firstName}, ${lastName}!`; 23 | 24 | // template literals with expression interpolation 25 | const price = 10; 26 | const VAT = 0.25; 27 | 28 | const total = `Total: ${(price * (1 + VAT)).toFixed(2)}`; 29 | ``` 30 | 31 | 32 | -------------------------------------------------------------------------------- /ne/numbers/README.md: -------------------------------------------------------------------------------- 1 | # Numbers (संख्याहरू) 2 | 3 | JavaScript has **only one type of number** – 64-bit float point. It's the same as Java's `double`. Unlike most other programming languages, there is no separate integer type, so 1 and 1.0 are the same value. Creating a number is easy, it can be done just like for any other variable type using the `var` keyword. 4 | 5 | जाभास्क्रिप्टमा **केवल एक प्रकारको नम्बर** - 64-बिट फ्लोट पोइन्ट छ। यो जाभाको `डबल` जस्तै हो। अधिकांश अन्य प्रोग्रामिंग भाषाहरूको विपरीत, त्यहाँ कुनै अलग पूर्णांक प्रकार छैन, त्यसैले १ र १.० समान मान हो। संख्या सिर्जना गर्न सजिलो छ, यो `var (वर)` कुञ्जीशब्द प्रयोग गरेर कुनै पनि अन्य चर प्रकारको लागि जस्तै गर्न सकिन्छ। 6 | 7 | Numbers can be created from a constant value: 8 | 9 | संख्याहरू स्थिर मानबाट सिर्जना गर्न सकिन्छ। 10 | 11 | ```javascript 12 | // This is a float: 13 | let a = 1.2; 14 | 15 | // This is an integer: 16 | let b = 10; 17 | ``` 18 | 19 | Or from the value of another variable: 20 | 21 | वा अर्को भ्यारीएबलको मानबाट। 22 | 23 | ```javascript 24 | let a = 2; 25 | let b = a; 26 | ``` 27 | 28 | The precision of integers is accurate up to 15 digits and the maximum number is 17. 29 | 30 | पूर्णांकको परिशुद्धता १५ अंकसम्म सही हुन्छ र अधिकतम संख्या १७ हुन्छ । 31 | 32 | ```javascript 33 | let x = 999999999999999; // x will be 999999999999999 34 | let y = 9999999999999999; // y will be 10000000000000000 35 | ``` 36 | 37 | It interprets numeric constants as hexadecimal if they are preceded by `0x`. 38 | 39 | यसले संख्यात्मक स्थिरांकलाई हेक्साडेसिमलको रूपमा व्याख्या गर्दछ यदि तिनीहरू `0x` भन्दा पहिले छन्। 40 | 41 | ```javascript 42 | let z = 0xFF; // 255 43 | ``` 44 | -------------------------------------------------------------------------------- /ne/objects/README.md: -------------------------------------------------------------------------------- 1 | # Objects (वस्तुहरू) 2 | 3 | In javascript the objects are **mutable** because we change the values pointed by the reference object, instead, when we change a primitive value we are changing its reference which now is pointing to the new value and so primitive are **immutable**. The primitive types of JavaScript are `true`, `false`, numbers, strings, `null` and `undefined`. Every other value is an `object`.Objects contain `propertyName`: `propertyValue` pairs. There are three ways to create an `object` in JavaScript: 4 | 5 | जाभास्क्रिप्टमा वस्तुहरू **उत्परिवर्तनीय** छन् किनकि हामी सन्दर्भ वस्तुद्वारा इंगित मानहरू परिवर्तन गर्दछौं, यसको सट्टा, जब हामी एक आदिम मान परिवर्तन गर्दछौं हामी यसको सन्दर्भ परिवर्तन गर्दैछौं जुन अब नयाँ मानलाई इंगित गर्दैछ र त्यसैले आदिम **अपरिवर्तनीय** हो। जाभास्क्रिप्टका आदिम प्रकारहरू 'सत्य', 'गलत', संख्याहरू, स्ट्रिङहरू, 'शून्य' र 'अपरिभाषित' हुन्। प्रत्येक अन्य मान एक 'वस्तु' हो। वस्तुहरूले 'गुणनाम' समावेश गर्दछ: 'गुणभ्यालु' जोडी । जाभास्क्रिप्टमा 'वस्तु' सिर्जना गर्ने तीन तरिकाहरू छन्: 6 | 7 | 1. literal (शाब्दिक) 8 | 9 | ```javascript 10 | let object = {}; 11 | // Yes, simply a pair of curly braces! 12 | ``` 13 | 14 | > _**Note:**_ this is the **recommended** way. 15 | 16 | > _**नोट:**_ यो **सिफारिस गरिएको** तरिका हो। 17 | 18 | 2. object-oriented (वस्तु उन्मुख) 19 | 20 | ```javascript 21 | let object = new Object(); 22 | ``` 23 | 24 | > _**Note:**_ it's almost like Java. 25 | 26 | > _**नोट:**_ यो लगभग जाभा जस्तै छ। 27 | 28 | 3. and using `object.create` 29 | 30 | ```javascript 31 | let object = Object.create(proto[, propertiesObject]); 32 | ``` 33 | 34 | > _**Note:**_ it creates a new object with the specified prototype object and properties. 35 | 36 | > _**नोट:**_ यसले निर्दिष्ट प्रोटोटाइप वस्तु र गुणहरूको साथ नयाँ वस्तु सिर्जना गर्दछ। 37 | 38 | -------------------------------------------------------------------------------- /ne/objects/mutable.md: -------------------------------------------------------------------------------- 1 | # Mutable (परिवर्तनीय) 2 | 3 | The difference between objects and primitive values is that **we can change objects**, whereas primitive values are **immutable**. 4 | 5 | वस्तुहरू र आदिम मानहरू बीचको भिन्नता यो हो कि **हामी वस्तुहरू** परिवर्तन गर्न सक्छौं, जबकि आदिम मानहरू **अपरिवर्तनीय** हुन्। 6 | 7 | For example: 8 | 9 | उदाहरणको लागी: 10 | 11 | ```javascript 12 | let myPrimitive = "first value"; 13 | myPrimitive = "another value"; 14 | // myPrimitive now points to another string. 15 | let myObject = { key: "first value" }; 16 | myObject.key = "another value"; 17 | // myObject points to the same object. 18 | ``` 19 | 20 | You can add, modify, or delete properties of an object using the dot notation or the square bracket notation. 21 | 22 | तपाईँले डट नोटेसन वा स्क्वायर कोष्ठक नोटेसन प्रयोग गरेर वस्तुको गुण थप्न, परिमार्जन गर्न वा मेट्न सक्नुहुन्छ । 23 | 24 | ```python 25 | let object = {}; 26 | object.foo = 'bar'; // Add property 'foo' 27 | object['baz'] = 'qux'; // Add property 'baz' 28 | object.foo = 'quux'; // Modify property 'foo' 29 | delete object.baz; // Delete property 'baz' 30 | ``` 31 | 32 | {% hint style="warning" %} 33 | 34 | 35 | Primitive values (such as numbers and strings) are immutable, while objects (such as arrays and objects) are mutable. 36 | 37 | आदिम मानहरू (जस्तै संख्या र स्ट्रिङहरू) अपरिवर्तनीय छन्, जबकि वस्तुहरू (जस्तै एरे र वस्तुहरू) परिवर्तनशील छन्। 38 | {% endhint %} 39 | -------------------------------------------------------------------------------- /ne/promise-async-await/README.md: -------------------------------------------------------------------------------- 1 | # Promise, async/await (प्रतिज्ञा, असिंक/प्रतीक्षा) 2 | 3 | -------------------------------------------------------------------------------- /ne/strings/length.md: -------------------------------------------------------------------------------- 1 | # Length (लम्बाइ) 2 | 3 | जाभास्क्रिप्टमा गुण `.length` प्रयोग गरेर स्ट्रिङमा कति क्यारेक्टरहरू छन् भनेर जान्न सजिलो छ। `लम्बाइ` गुणले स्ट्रिङमा क्यारेक्टरहरूको संख्या फर्काउँछ, खाली स्थान हरू र विशेष क्यारेक्टरहरू सहित। 4 | 5 | 6 | ```javascript 7 | 8 | let size = "Our lovely string".length; 9 | console.log(size); 10 | // size: 17 11 | 12 | let emptyStringSize = "".length 13 | console.log(emptyStringSize); 14 | // emptyStringSize: 0 15 | 16 | ``` 17 | 18 | The length property of an empty string is `0`. 19 | 20 | खाली स्ट्रिङको लम्बाइ गुण `०` हो । 21 | 22 | {% hint style="warning" %} 23 | 24 | 25 | The `length` property is a read-only property, so you cannot assign a new value to it. 26 | 27 | `लम्बाइ` गुण पढ्नका लागि मात्र प्रयोग गरिने गुण हो, त्यसैले तपाईँले यसमा नयाँ मान निर्दिष्ट गर्न सक्नुहुन्न । 28 | {% endhint %} 29 | -------------------------------------------------------------------------------- /ne/strings/replace.md: -------------------------------------------------------------------------------- 1 | # Replace (प्रतिस्थापन) 2 | 3 | The `replace` method allows us to replace a character, word, or sentence with a string. For example. 4 | 5 | `प्रतिस्थापन` विधिले हामीलाई क्यारेक्टर, शब्द वा वाक्यलाई स्ट्रिङले प्रतिस्थापन गर्न अनुमति दिन्छ। उदाहरणका लागि: 6 | 7 | ```javascript 8 | let str = "Hello World!"; 9 | let new_str = str.replace("Hello", "Hi"); 10 | 11 | console.log(new_str); 12 | 13 | // Result: Hi World! 14 | ``` 15 | 16 | {% hint style="warning" %} 17 | 18 | 19 | To replace a value on all instances of a [regular expression](../regular-expression.md) with a `g` modifier is set. 20 | 21 | [परिमार्जकसँग](../regular-expression.md) नियमित अभिव्यक्तिको सबै उदाहरणहरूमा मान प्रतिस्थापन गर्न सेट गरिएको छ। 22 | 23 | {% endhint %} 24 | 25 | It searches for a string for a value or a regular expression and returns a new string with the value(s) replaced. It doesn't change the original string. Let's see the global case-insensitive replacement example. 26 | 27 | यसले मान वा नियमित अभिव्यक्तिका लागि स्ट्रिङ खोजी गर्दछ र मान(हरू) प्रतिस्थापन गरिएको नयाँ स्ट्रिङ फर्काउँछ । यसले मूल स्ट्रिङ परिवर्तन गर्दैन। आउनुहोस् विश्वव्यापी केस-असंवेदनशील प्रतिस्थापन उदाहरण हेरौं। 28 | 29 | ```javascript 30 | let text = "Mr Blue has a blue house and a blue car"; 31 | let result = text.replace(/blue/gi, "red"); 32 | 33 | console.log(result); 34 | //Result: Mr red has a red house and a red car 35 | ``` 36 | 37 | -------------------------------------------------------------------------------- /ne/template-literals/debugging.md: -------------------------------------------------------------------------------- 1 | # Debugging (डिबगिंग) 2 | 3 | In programming, errors can occur while writing code. It could be due to syntactical or logical errors. The process of finding errors can be time-consuming and tricky and is called code debugging. 4 | 5 | प्रोग्रामिंगमा, कोड लेख्दा त्रुटिहरू हुन सक्छ। यो वाक्यात्मक वा तार्किक त्रुटिहरूको कारण हुन सक्छ। त्रुटिहरू फेला पार्ने प्रक्रिया समय-खपत र पेचिलो हुन सक्छ र यसलाई कोड डिबगिंग भनिन्छ। 6 | 7 | Fortunately, most modern browsers come with built-in debuggers. These debuggers can be switched on and off, forcing errors to be reported. It is also possible to set up breakpoints during the execution of code to stop execution and examine variables. For this one has to open a debugging window and place the `debugger` keyword in the JavaScript code. The code execution is stopped in each breakpoint, allowing developers to examine the JavaScript values and, resume the execution of code. 8 | 9 | सौभाग्यवश, अधिकांश आधुनिक ब्राउजरहरू बिल्ट-इन डिबगरहरूसँग आउँछन्। यी डिबगरहरू स्विच अन र अफ गर्न सकिन्छ, जसले त्रुटिहरू रिपोर्ट गर्न बाध्य पार्छ। कार्यान्वयन रोक्न र चरहरूको जाँच गर्न कोडको कार्यान्वयनको क्रममा ब्रेकपोइन्टहरू सेट अप गर्न पनि सम्भव छ। यसको लागि डिबगिङ विन्डो खोल्नुपर्छ र जाभास्क्रिप्ट कोडमा 'डिबगर' कीवर्ड राख्नुपर्छ। कोड कार्यान्वयन प्रत्येक ब्रेकपोइन्टमा रोकिन्छ, विकासकर्ताहरूलाई जाभास्क्रिप्ट मानहरू जाँच गर्न र कोडको कार्यान्वयन पुन: सुरु गर्न अनुमति दिन्छ। 10 | 11 | One can also use the `console.log()` method to print the JavaScript values in the debugger window. 12 | 13 | डिबगर सञ्झ्यालमा जाभास्क्रिप्ट मान मुद्रण गर्न `console.log()` विधि पनि प्रयोग गर्न सकिन्छ । 14 | 15 | ```javascript 16 | const a = 5, b = 6; 17 | const c = a + b; 18 | console.log(c); 19 | // Result : c = 11; 20 | ``` 21 | -------------------------------------------------------------------------------- /ne/template-literals/global-footprint.md: -------------------------------------------------------------------------------- 1 | # Global footprint (ग्लोबल पदचिह्न) 2 | 3 | If you are developing a module, which might be running on a web page, which also runs other modules, then you must beware of the variable name overlapping. 4 | 5 | यदि तपाईं मोड्युल विकास गर्दै हुनुहुन्छ, जुन वेब पृष्ठमा चलिरहेको हुन सक्छ, जसले अन्य मोड्युलहरू पनि चलाउँदछ, त्यसपछि तपाईंले चर नाम ओभरल्यापिङको बारेमा सावधान हुनुपर्दछ। 6 | 7 | Suppose we are developing a counter module: 8 | 9 | मानौं हामी काउन्टर मोड्युल विकास गर्दैछौं: 10 | 11 | ```javascript 12 | let myCounter = { 13 | number: 0, 14 | plusPlus: function () { 15 | this.number = this.number + 1; 16 | }, 17 | isGreaterThanTen: function () { 18 | return this.number > 10; 19 | }, 20 | }; 21 | ``` 22 | 23 | > _**Note:**_ this technique is often used with closures, to make the internal state immutable from the outside. 24 | 25 | > _**नोट:**_ आन्तरिक अवस्थालाई बाहिरबाट अपरिवर्तनीय बनाउन यो प्रविधि प्रायः बन्द गरेर प्रयोग गरिन्छ। 26 | 27 | The module now takes only one variable name — `myCounter`. If any other module on the page makes use of such names like `number` or `isGreaterThanTen` then it's perfectly safe because we will not override each other's values. 28 | 29 | मोड्युलले अब केवल एक चर नाम लिन्छ - `myCounter`। यदि पृष्ठमा कुनै अन्य मोड्युलले 'नम्बर' वा `isGreaterThanTen` जस्ता नामहरू प्रयोग गर्दछ भने यो पूर्ण रूपमा सुरक्षित छ किनकि हामी एक अर्काको मानहरू ओभरराइड गर्नेछैनौं। 30 | -------------------------------------------------------------------------------- /ne/template-literals/linked-list/README.md: -------------------------------------------------------------------------------- 1 | # Linked List (लिङ्क गरिएको सूची) 2 | 3 | It is a common data structure found in all programming languages. A Linked List is very similar to a normal array in Javascript, it just acts a little bit differently. 4 | 5 | यो सबै प्रोग्रामिंग भाषाहरूमा पाइने एक सामान्य डेटा संरचना हो। लिङ्क गरिएको सूची जाभास्क्रिप्टमा सामान्य सरणीसँग धेरै मिल्दोजुल्दो छ, यसले थोरै फरक तरिकाले कार्य गर्दछ। 6 | 7 | Here each element in the list is a separate object containing a link or a pointer to the next. There is no built-in method or function for Linked Lists in Javascript so one has to implement it. An example of a linked list is shown below. 8 | 9 | यहाँ सूचीको प्रत्येक तत्व एक अलग वस्तु हो जसमा लिङ्क वा अर्कोमा सूचक हुन्छ। जाभास्क्रिप्टमा लिङ्क गरिएको सूचीहरूको लागि कुनै बिल्ट-इन विधि वा प्रकार्य छैन त्यसैले यसलाई कार्यान्वयन गर्नु पर्दछ। लिङ्क गरिएको सूचीको उदाहरण तल देखाइएको छ। 10 | 11 | ``` 12 | ["one", "two", "three", "four"] 13 | ``` 14 | 15 | **Types of Linked Lists** 16 | 17 | There are three different types of linked lists: 18 | 19 | 1. **Singly Linked Lists:** Each node contains only one pointer to the next node. 20 | 2. **Doubly Linked Lists:** There are two pointers at each node, one to the next node and one to the previous node. 21 | 3. **Circular Linked Lists:** A circular linked list forms a loop by having the last node pointing to the first node or any other node before it. 22 | 23 | **लिंक गरिएको सूचीको प्रकार** 24 | 25 | त्यहाँ तीन प्रकारका लिङ्क गरिएका सूचीहरू छन्: 26 | 27 | 1. **एकल लिङ्क सूचीहरू:** प्रत्येक नोडले अर्को नोडमा केवल एक सूचक समावेश गर्दछ। 28 | 2. **डबल लिङ्क गरिएको सूचीहरू:** प्रत्येक नोडमा दुई पोइन्टरहरू छन्, अर्को नोडमा एक र अघिल्लो नोडमा एक। 29 | 3. **सर्कुलर लिङ्क गरिएको सूचीहरू:** एक परिपत्र लिङ्क गरिएको सूचीले अन्तिम नोडलाई पहिलो नोड वा यसको अगाडि कुनै अन्य नोडलाई इंगित गरेर लूप बनाउँदछ। 30 | -------------------------------------------------------------------------------- /ne/template-literals/linked-list/add.md: -------------------------------------------------------------------------------- 1 | # Add (जोड्नु) 2 | 3 | The `add` method is created here to add value to a linked list. 4 | 5 | लिङ्क गरिएको सूचीमा मान थप्न यहाँ `add` विधि सिर्जना गरिएको छ । 6 | 7 | ```javascript 8 | class Node { 9 | constructor(data) { 10 | this.data = data 11 | this.next = null 12 | } 13 | } 14 | 15 | class LinkedList { 16 | constructor(head) { 17 | this.head = head 18 | } 19 | append = (value) => { 20 | const newNode = new Node(value) 21 | let current = this.head 22 | if (!this.head) { 23 | this.head = newNode 24 | return 25 | } 26 | while (current.next) { 27 | current = current.next 28 | } 29 | current.next = newNode 30 | } 31 | } 32 | ``` 33 | -------------------------------------------------------------------------------- /ne/template-literals/linked-list/pop.md: -------------------------------------------------------------------------------- 1 | # Pop (पप) 2 | 3 | Here, a `pop` method is created to remove a value from the linked list. 4 | 5 | यहाँ, लिङ्क गरिएको सूचीबाट मान हटाउन 'पप' विधि सिर्जना गरिएको छ। 6 | 7 | ```javascript 8 | class Node { 9 | constructor(data) { 10 | this.data = data 11 | this.next = null 12 | } 13 | } 14 | 15 | class LinkedList { 16 | constructor(head) { 17 | this.head = head 18 | } 19 | pop = () => { 20 | let current = this.head 21 | while (current.next.next) { 22 | current = current.next 23 | } 24 | current.next = current.next.next 25 | } 26 | } 27 | ``` 28 | -------------------------------------------------------------------------------- /ne/template-literals/linked-list/prepend.md: -------------------------------------------------------------------------------- 1 | # Prepend (प्रिपेन्ड) 2 | 3 | Here, a `prepend` method is created to add a value before the first child of the linked list. 4 | 5 | यहाँ, लिङ्क गरिएको सूचीको पहिलो बच्चा भन्दा पहिले मान थप्न 'प्रिपेन्ड' विधि सिर्जना गरिएको छ। 6 | 7 | ```javascript 8 | class Node { 9 | constructor(data) { 10 | this.data = data 11 | this.next = null 12 | } 13 | } 14 | 15 | class LinkedList { 16 | constructor(head) { 17 | this.head = head 18 | } 19 | prepend = (value) => { 20 | const newNode = new Node(value) 21 | if (!this.head) { 22 | this.head = newNode 23 | } 24 | else { 25 | newNode.next = this.head 26 | this.head = newNode 27 | } 28 | } 29 | } 30 | ``` 31 | -------------------------------------------------------------------------------- /ne/template-literals/linked-list/shift.md: -------------------------------------------------------------------------------- 1 | # Shift (सिफ्ट) 2 | 3 | Here, the `shift` method is created to remove the first element of the Linked List. 4 | 5 | यहाँ, लिङ्क गरिएको सूचीको पहिलो तत्व हटाउन 'सिफ्ट' विधि सिर्जना गरिएको छ। 6 | 7 | ```javascript 8 | class Node { 9 | constructor(data) { 10 | this.data = data 11 | this.next = null 12 | } 13 | } 14 | 15 | class LinkedList { 16 | constructor(head) { 17 | this.head = head 18 | } 19 | shift = () => { 20 | this.head = this.head.next 21 | } 22 | } 23 | ``` 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "javascript_tutorial", 3 | "version": "1.0.0", 4 | "description": "Learn JavaScript", 5 | "main": "index.js", 6 | "devDependencies": { 7 | "gitbook-plugin-edit-link": "^2.0.2", 8 | "gitbook-plugin-chapter-fold": "^0.0.4", 9 | "gitbook-plugin-exercises": "^3.0.0", 10 | "gitbook-plugin-favicon-custom": "^1.0.0", 11 | "gitbook-plugin-hide-published-with": "0.0.1", 12 | "gitbook-plugin-hints": "^1.0.2", 13 | "gitbook-plugin-intopic-toc": "^1.0.6", 14 | "gitbook-plugin-sharing": "https://github.com/sumn2u/plugin-sharing.git", 15 | "gitbook-plugin-sidebar-ad": "0.0.4", 16 | "gitbook-plugin-sitemap": "^1.2.0", 17 | "gitbook-plugin-theme-creative": "^1.0.6", 18 | "honkit": "^4.0.4", 19 | "honkit-plugin-i18nsettings": "^1.0.0" 20 | }, 21 | "scripts": { 22 | "start": "honkit serve", 23 | "build": "exit 0" 24 | }, 25 | "keywords": [], 26 | "author": "Suman Kunwar", 27 | "license": "CC-BY-SA-4.0" 28 | } 29 | -------------------------------------------------------------------------------- /star_us.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/learn-javascript/8eb987d3daecda933811be345d947165111bdde4/star_us.gif --------------------------------------------------------------------------------