Tutorialspoint

Javascript Programming Examples

usage of charAt() method in javascript

<html>
<body>
<script>
   var string = "Tutorix is a best e-learning platform";
   var result = string.charAt(11)
   document.write(result);
</script>
</body>
</html>

charAt() method usage in javascript

<html>
<body>
<p id="character"></p>
<script>
   var string = "TUTORIALSPOINT AND TUTORIX";
   var result = string.charAt(9)
   document.getElementById("character").innerHTML = result;
</script>
</body>
</html>

use of array.entries() method in javascript

<html>
    <body>
        <script>
        var elements = ["Helium", "Neon", "Krypton", "Xenon", "Radon"];
        var iterator = elements.entries();
        document.write(iterator.next().value);
        document.write("</br>");
        document.write(iterator.next().value);
        </script>
    </body>
</html>

use of Math.round() method in javascript

<html>
<body>
<script>
   document.write(Math.round(5.34));
</script>
</body>
</html>

Use of Math.ceil() method in javascript

<html>
<body>
<script>
   document.write(Math.ceil(5.34));
</script>
</body>
</html>

use of slice() method in javascript

<html>
<body>
<p id="slice"></p>
<script>
var string = "Tesla, Solarcity, Neuralink, Spacex";
var newstring = string.slice(18,27);
document.getElementById("slice").innerHTML = newstring;
</script>
</body>
</html>

use of substr() method in javascript

<html>
<body>
<p id="substring"></p>
<script>
var str = "Tesla, Spacex, Neuralink, Solarcity";
var res = str.substr(7,17);
document.getElementById("substring").innerHTML = res;
</script>
</body>
</html>

Math.pow() method with negative parameters in javascript

<html>
<body>
<script>
document.write(Math.pow(-9, 3));
</script>
</body>
</html>

Math.pow() method with fractions in javascript

<html>
<body>
<script>
document.write(Math.pow(27, 1/3));
</script>
</body>
</html>

Math.pow() method with positive values in javascript

<html>
<body>
<script>
document.write(Math.pow(9, 3));
</script>
</body>
</html>

1 2 3 4 5 6 7 ... 271 Next
Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.