Skip to main content

Arrays and conversion in Javascript || javascript complete course || #7 (sourcecode)

hey guys how are you all today in this post I am going to give you the source code of my video called arrays and  conversion in JavaScript so let's begin:-

// ARRAYS in javascript

console.log("This is arrays in js")
var arr1 = [32,34,23,23,234,"this",
{
    name:"Gautam",
    class : "8th",
    rollno: 6
}
]


console.log(arr1)


console.log(arr1[5])
console.log(arr1.length)
console.log(arr1.concat('main'));
console.log(arr1);
// // ----------------------------------------------------
// CONVERSION IN JAVASCRIPT
// Converting in to strings
var num1 = 45;
console.log(num1);
var str1 = String(num1);
console.log(str1);
console.log(typeof str1);
console.log(typeof num1);

var number1 = 33453434;
console.log(number1,typeof number1);
var string1 = number1.toString();
console.log(string1,typeof string1);
// -----------------------------------------------------------
// Converting to numbers
// Way1:
var myname = "01010d101"; // this will return NaN which means not a number because it includes alphabets.
console.log(myname,typeof myname);
var mynameinnum = Number(myname)
console.log(mynameinnum, typeof mynameinnum)
var boolean1 = true;
console.log(boolean1, typeof boolean1)
console.log(Number(boolean1),typeof Number(boolean1));
var boolean2 = false;
console.log(boolean2,typeof boolean2)
console.log(Number(boolean2),typeof Number(boolean2));
var num1 = 32;
console.log(num1)
var float1 = parseFloat(num1);
console.log(float1);
var float2 = 23423.324444444;
console.log(float2)
var int1 = parseInt(float2);
console.log(int1)

I hope that you liked this post.
Like, share, subscribe to the channel and the video.
Thank You.

Comments

Popular posts from this blog

How to create a Personal Portfolio website [source code]

  Hey guys how are you all today in this post I am going to give you the source code of my portfolio website’s part 1st video so let’s begin with this post:- Source code of Index.html file:- <DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Gautam Sharma</title> <link rel="stylesheet" href="../CSS-Files/style.css"> <link rel="stylesheet" href="../CSS-Files/utils.css"> </head> <body> <header> <nav> <li><a href="./index.html">Home</a></li> <li><a href="./Contact.html">Contact</a></li> <li><a href="./Haier.html"

Step by step guide to coding a game in Python

  How to Code a Simple Game in Python Python is a powerful and versatile programming language that can be used for a wide range of applications, including game development. In this tutorial, we will be creating a simple game using the Pygame library in Python. Pygame is a set of Python modules designed for writing video games. It provides functionality for creating 2D graphics, handling events, and playing sounds and music. By the end of this tutorial, you will have a basic understanding of how to create a game using Pygame and Python. Setting up the Development Environment Before we can start coding our game, we must set up our development environment. To do this, we will need to install Python and the Pygame library. If you already have Python installed on your machine, you can install Pygame by running the following command in your terminal: pip install pygame If you don't have Python installed, you can download the latest version from the official Python website. Once you have

How to write youtube channel description

Hey guys how are you all today in this post I am going to tell you that How to write youtube channel description . So if you want to know that how to write youtube channel description  then it is very easy there are simple tips for writing youtube channel description so now without any delay let's begin with this post:- watch the complete video here:-  https://youtu.be/CmZmozRmSFk   so guys if you want to write your channel description then you have to firstly learn that from where you have to edit your YouTube channel description. Firstly you have to open the YouTube Studio  website from there  you have to move to the customization tab. Now you have to go to the basic info option and from here youtube can edit your youtube channel description easily. How to write youtube channel description (Tips) In the first paragraph write a text which welcomes the viewer like the first paragraph of my post. In the second one write about your channel what you cover in that youtube channel etc.