Teachnique
      CourseRoadmaps
      Login

      OverviewPlacementSyntaxHello WorldConsole.log()CommentsVariableslet StatementConstantsData TypesType ConversionsStrict ModeReserved Keywords

      OperatorsArithmetic OperatorsComparison OperatorsLogical OperatorsBitwise OperatorsAssignment OperatorsConditional Operatorstypeof OperatorNullish Coalescing OperatorDelete OperatorComma OperatorGrouping OperatorYield OperatorSpread OperatorExponentiation OperatorOperator Precedence

      If...ElseWhile LoopsFor LoopFor...in LoopFor...of LoopLoop ControlBreak StatementContinue StatementSwitch CaseUser Defined Iterators

      FunctionsFunction ExpressionsFunction ParametersDefault ParametersFunction() ConstructorFunction HoistingArrow FunctionsFunction InvocationFunction call() MethodFunction apply() MethodFunction bind() MethodClosuresVariable ScopeGlobal VariablesSmart Function Parameters

      NumberBooleanStringsArraysDateMathRegExpSymbolSetsWeakSetMapsWeakMapIterablesReflectTypedArrayTempate LiteralsTagged Templates

      Objects OverviewClassesObject PropertiesObject MethodsStatic MethodsDisplay ObjectsObject AccessorsObject ConstructorsNative PrototypesES5 Object MethodsEncapsulationInheritanceAbstractionPolymorphismDestructuring AssignmentObject DestructuringArray DestructuringNested DestructuringOptional ChainingGlobal ObjectMixinsProxies

      HistoryVersionsES5ES6ECMAScript 2016ECMAScript 2017ECMAScript 2018ECMAScript 2019ECMAScript 2020ECMAScript 2021ECMAScript 2022

      CookiesCookie AttributesDeleting Cookies

      Browser Object ModelWindow ObjectDocument ObjectScreen ObjectHistory ObjectNavigator ObjectLocation ObjectConsole Object

      Web APIHistory APIStorage APIForms APIWorker APIFetch APIGeolocation API

      EventsDOM Events

      Feedback

      Submit request if you have any questions.

      Course
      Comments

      JavaScript Tutorial

      This JavaScript tutorial is crafted for beginners to introduce them to the basics and advanced concepts of JavaScript. By the end of this guide, you'll reach a proficiency level that sets the stage for further growth. Aimed at empowering you to progress towards becoming a world-class software developer, this tutorial paves the way for a successful career in web development and beyond.

      Comments

      JavaScript Comments

      In JavaScript, comments are used to add explanatory notes within the code. These comments are not executed by the browser and are purely for human understanding.
      There are two ways to add comments in JavaScript:
      • Single-line Comments: Single-line comments start with // and continue until the end of the line. They are useful for adding short explanations or notes.
      <html>
      <head>
      <title> Single line comments </title>
      </head>
      <body>
      <script>
      // Defining the string1
      var string1 = "JavaScript";
      // Defining the string2
      var string2 = "TypeScript";
      // Printing the strings
      document.write(string1, " ", string2);
      </script>
      </body>
      </html>
      • Multi-line Comments: Multi-line comments begin with /* and end with */. They can span across multiple lines and are typically used for longer descriptions or commenting out blocks of code.
      <html>
      <head>
      <title> Multi line comments </title>
      </head>
      <body>
      <script>
      var a = 100;
      var b = 200;
      
      /* a = a + b;
      b = a - b;
      a = a - b; */
      
      document.write("a = " + a + "<br>" + "b = " + b);
      </script>
      </body>
      </html>