Author: admin

  • Modules and Mixins

    Modules are a way of grouping together methods, classes, and constants. Modules give you two major benefits. Modules define a namespace, a sandbox in which your methods and constants can play without having to worry about being stepped on by other methods and constants. Syntax Module constants are named just like class constants, with an…

  • Blocks

    You have seen how Ruby defines methods where you can put number of statements and then you call that method. Similarly, Ruby has a concept of Block. Syntax Here, you will learn to invoke a block by using a simple yield statement. You will also learn to use a yield statement with parameters for invoking a block. You will…

  • Methods

    Ruby methods are very similar to functions in any other programming language. Ruby methods are used to bundle one or more repeatable statements into a single unit. Method names should begin with a lowercase letter. If you begin a method name with an uppercase letter, Ruby might think that it is a constant and hence…

  • Loops

    Loops in Ruby are used to execute the same block of code a specified number of times. This chapter details all the loop statements supported by Ruby. Ruby while Statement Syntax Executes code while conditional is true. A while loop’s conditional is separated from code by the reserved word do, a newline, backslash \, or a semicolon ;. Example This will produce the following result…

  • Hello World Program

    Write “Hello World” Program in JavaScript “Hello, World!” is often the first program, programmers write when learning a new programming language. JavaScript “Hello World” is a simple program, generally used to demonstrate the basic syntax of the language. This program will make use of different JavaScript methods to print “Hello World”. Using document.write() In JavaScript,…

  • Syntax

    JavaScript Syntax JavaScript syntax comprises a set of rules that define how to construct a JavaScript code. JavaScript can be implemented using JavaScript statements that are placed within the <script>… </script> HTML tags in a web page. You can place the <script> tags, containing your JavaScript, anywhere within your web page, but it is normally recommended that you should…

  • if…else, case, unless

    Ruby offers conditional structures that are pretty common to modern languages. Here, we will explain all the conditional statements and modifiers available in Ruby. Ruby if…else Statement Syntax end if expressions are used for conditional execution. The values false and nil are false, and everything else are true. Notice Ruby uses elsif, not else if nor elif. Executes code if the conditional is true.…

  • Placement in HTML File

    JavaScript Placement in HTML File There is flexibility to place JavaScript code anywhere in an HTML document. However, the most preferred ways to include JavaScript in an HTML file are as follows − You can follow the syntax below to add JavaScript code using the script tag. In the following section, we will see how we can…

  • Operators

    Ruby supports a rich set of operators, as you’d expect from a modern language. Most operators are actually method calls. For example, a + b is interpreted as a.+(b), where the + method in the object referred to by variable a is called with b as its argument. For each operator (+ – * / % ** & |…

  • Enabling JavaScript in Browsers

    Enabling JavaScript All modern browsers come with built-in support for JavaScript, and it has enabled JavaScript by default. Frequently, you may need to enable or disable this support manually. This chapter explains how to turn JavaScript support on and off in your browsers: Chrome, Microsoft Edge, Firefox, Safari, and Opera. JavaScript in Chrome Here are…