NUMBER OBJECTS || NUMBER METHODS || NUMBER CONVERSIONS || NUMBER PROPERTIES IN JAVA SCRIPT

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello friends welcome back to our channel so in today's session we will discuss about the number object so in the previous sessions we have discussed about numbers but in today's session we will discuss about number object see coming to the number objects so it is completely different with the numbers okay so if we are creating some variable some x is equal to 10 so this x is of type number similarly if you are declaring some variable with y is equal to sub 2.5 this will also be of number so one thing how how can we know whether the given uh variable is of which data type that means either it is a number or a string so for finding this one we are having a small keyword called type off so by using this type of we can know what exactly the data type of the particular variable so if you want to check the ex we have to go with type of ex so it will give either number or a string or it's an object okay a number string or object whatever it may be the data type of this variable will be given here so if you want to create a number object then this number object can be created by using new keyword new keyword okay so how to create a number object similarly where x is equal to nu number n should be capital here number of give the value here some 10 right now the type of x is an object it's not a number in this case the type of x is number right and in this case type of x will be object object so objects will be created with the help of a new keyboard right now if you compare these two things okay if you compare these two things for example consider y here okay consider y here so x is equal to 10 and remove this one x is equal to 10 and y is equal to 10 if you compare x is equal to is equal to y x is equal to is equal to y automatically this will return true because because it will compare the values compare values okay so the value of x is 10 here and here also the value of y is 10 so x is equal to is equal to y is true and if you go with triple is equal to so here there is a one more operator is equal to so triple is equal to then it will return false because it will compare data types so it will compare types so here x type is number y type is object so both are different so if you compare these two we'll get the false as a result and similarly see where z is equal to some new number of 10 so here you can observe so here j this is also an object right that is also an object y is object that is object and if you compare this to y is equal to is equal to j it will return false and it will always return false because we can't compare we can't compare the objects so object should not be compared okay we can't compare the objects so this is the difference between all these things okay this is the difference between all these things so is equal to triple is equal to and again equal to so if both are values then we have to use a double is equal to if both are types if you want to compare the times we have to use the triple is equal to and object should not be compared now let us move with the methods so there are a few methods that can be applied on these numbers and the number objects so now number methods will go with the number methods so one method we have seen in the previous session that is a two string two string so this two string will be uh returning the string from any other variable right so converts to string data type converts to string data type for example where x is sorry for where x is equal to 10 here 10 is a number so x dot 2 string so yes s is a capital right s is a capital it will return 10 as a string 10 as a string similarly some float value can also be converted into a string and also if you give any base value here automatically it will convert from one number system to another number system right so this is one method and the second method is to exponential to exponential so here we have to give the value here and whatever the value are given that will be applied to the number and that number will be represented in a scientific uh manner that means exponential with the help of exponential right so i will show you an example by executing small port and there is one more method called to fix it to fix it and here also we have to give the value so that the value will be taken consideration and it will be rounding up the number right for example if a is a is equal to 5.4567 and if you are doing a dot to fix it f is capital here to fix it of two so only two decimals will be taken up to two decimals so a value becomes after executing this one five point four five so four five will be rounded so four six will be printed here four six will be printed okay so five point four five six seven so a to a dot two fixture of two that means it will round up to two values so four five it will display four six right if you are giving three then four five six so it will print four five seven it will round up the third up to third value so i will execute the program so that you will uh your doubt should be clarified right now again there is a one more function called to precision to precision and give the value and this gives the length of the number length of the number so how many numbers how many digits should be uh accepted for example similarly a five is for a is equal to four point four five six seven and a dot two precision a dot to precision of three so it will return only three the length of the value should be three so it will return so five point four five so total values are five oh three okay total number of the length of the number is three so this value represents the length of the number okay if it is a four so automatically four five six so total length is four so like this we can use this to precision to reduce or increase the value of the length of the band the length of the number right so i will i will execute all these functions these are the methods available and i will execute all these methods by in the in the html code we write some html code and it will execute all these things and after the methods now so whatever the methods we are using uh either two string or two fixed or two exponential or two precision the return state the return value will be in the form of string okay so for example some a is equal to five point four five six seven and a dot 2 precision 2 precision of 3 the result will be 5.45 and this is in the form of string this is this will be in the form of string so we need to convert into numbers if you want to convert into a numbers there are some number conversions there are some number conversions so which will convert the variables to numbers variables to numbers variables to numbers so for this we are having the functions called number parse in parse flow okay so these functions will convert the variables to numbers so for example you you take this one and if you initialize it to any other variable so b will be having some 5.45 if you pass this b here automatically the data type of b will be number the data type of variable b will be changed to number so initially now so whatever the uh i mean value we are applied to the precision the result will be in the string and again if you are passing the value to the number function or parsing function or a parse float function we will get the result as a number so this will give the result as five point four five it's a number and if you give this here it will return only five if you give here we will read it will return five point four four five right so like that we can convert the variables to numbers by using one among these three functions number function parseint and a parse float right and apart from these conversions we are also having some properties number properties so for variables we can't apply these properties for only the numbers we can apply the properties so there are different properties those are called number properties number properties so this can be applied only for the numbers right so the first one is capital letters min underscore value so this will return the minimum value minimum value that the java script variable will hold okay second one is a maximum value next underscore value all are the capital letters this will give the maximum value that a variable can store in javascript okay that available can store in javascript a maximum value and a minimum value and the third one positive underscore infinity so this will return the infinitive n infinity that means a divided by 0 okay so this is a plus positive infinity and next one is a negative infinity all our capital letters this will give negative infinity see for example this is an example 10 divided by 0 it will give the positive infinity minus 10 divided by 0 it will give the negative infinity so this is negative infinity and the last one is nan it is nothing but not a number not a number so i think in the previous session we have gone through this nand not a number so if any expression is having a non-numeric string and it is applied to the arithmetic operations then we'll get this not a number non-numeric string that means the string should not contain any alphabets sorry digits right for example some 10 divided by abc so this is a non-numeric string but applying some argument operation similarly 10 plus sorry not not the plus so if you use a plus automatically it will use a concatenation 10 minus abc this will also give the not a number similarly 10 into abc this will also return the non norton number but if you give 10 plus abc what is the result in the previous session we have seen can concatenation will be done so 10 abc will be the result here in this case only in the edition arithmetic edition so all the remaining cases will get the result as not a number not a number right so these are the number properties and these properties are only valid for numbers okay only valid for number object it doesn't uh suitable for variables it will not be applied for variables right so hope you understood this one so let us demonstrate i will demonstrate all these things by executing a small html code so let's move on to the system so that if you are still having any doubts all the doubts will be clarified once you see the program right so let's move on to the system hello friends so just now we have seen the number object so how to create a number object and how it differs from the normal number and then different methods available in this number object and also we have seen a different conversion functions that means number function parsing function and pass float and also we have seen the properties of number object right now let us demonstrate all these things by executing a small html code so let us start writing the html code so let us start with the html text so inside the html tag we have to write the body so inside the body we can write the content so body tag so yeah put the heading here just i will give the heading as number objects right now so here i will write let us write the script here inside the body so inside the script we can write all the things so first we will create a number a normal number and a number object so in order to create a normal number we can go with where some x is equal to some 10 or 15 right so let us take from 15 and let us create an object so object is created with the help of a new keyword so y is equal to some new keyword followed by the number and whatever the number we are giving here we have to pass now you can observe here uh i have given the two things here x is in number and y is an object so x is a variable and y is an object so how to know whether x is a variable or object that means how to know the type of that particular variable so here we can have we are having one keyword that is a type of so by using this type of statement we can know whether the x or y or variables the variables of particular data type so let us check with that one so for that i will go with the some z is equal to sorry so document dot write ln so i will write some this function to print the output so here i will go with the type of uh x right so i will write here type of x right now sorry yeah and then also write the same thing in order to know the type of y okay type of file type of file so we'll get the data type of x and a data type of y here let us save this one with the help of uh numbers.html right so we'll save this one the numbers.html so you can find here by executing this one we'll get the data types so you can update here type of x is number a type of y is object so we we'll take a br okay that means a break room and also here i will include this one because whatever the thing we are printing in the next lines that will be printed in a new line so just refresh it so type of x is number and type of y is undefined for here by 4 now you can observe type of y is object so here here x is having 15 and y is having 15 and if you are comparing the things see if you are comparing the things write the same thing see x is equal to is equal to y that means so instead of writing here just write x equal to equal to y now what is the result observe here so we'll get true what's the result of here it's a true x is equal to y is true right so because uh here double is equal to is an equal is nothing but a relational operator whenever you are using this double is equal to it checks the value so value of x is 15 and y is 15 so it becomes true and if you go with the triple equal to triple is equal to that implies it it compares the types not the values okay so here type of x is intege number and type of y is object now we get the result as sorry see i will i will copy the same thing and i will go with this next so here we will go with the triple is equal to now the result will be false the result is a false here okay the result is a false here so here the result is a false why it is false because we are using some triple is equal to which means it compares the data types okay if it is double equal to it is a values that values will be compiled if it is equal to the tags will be compared and one more thing we can't compare the objects so for example you take the same thing you take one more variable here some z sub z that is equal to 15 and also you can print the type of jet okay the type of jet is nothing but an object right so type of jet is an object because we are using some new and if you compare the same thing if you compare the same thing with z y and z okay so you can observe here both are objects right both are objects so here i am comparing the y and z so even though both are objects will get the result as false okay because two objects can't be compared so this this point should be remembered two objects can't be compared right so this is a number object so the like this we can create an object that means by using the new keyword new keyword now there are different methods available in number object that is first one is a two string so already we have seen in the uh in the previous session that is the two string in order to convert from one base value to another base value so that base value will be given as an argument to the two string function so if you are not giving any argument there the value will be converted into a string data type so here you can observe x is nothing but a 15 and now where s is equal to write down x dot to string to string so automatically yes is a type of string so 15 will be converted into a string type so you can observe here so here type of yes you can observe here type of yes is a string okay so yes x dot to string means whatever the number we are giving either integer or a float numerical value will be converted into a numeric string it's a numeric string now right then there is a one more function called two exponential so we can represent any value with the exponential form see you take the same thing so where some e is equal to exponential so we'll consider 15 itself 50 x dot to exponential right and give the value to which it must be exponential so 2 i'll give 2 and i will print e value here i will print e value so i will remove all these things okay i will remove these things and also yeah i will remove these things so that there will be no confusion for you so instead of giving here exponential form it's nothing but e so if you print e you'll get the value in exponential form you can observe here say exponential form 1.50 e plus 1 right so representing the value the representing the value in terms of exponential if you go with the 3 you can observe here so three these are three uh precisions right three decimals three decimals with exponential value right so this is how we can convert any number to exponential form okay now there is one more function called fixed to fixed to fixed function will returns a string and it gives the number of decimals it will restrict to the number of decimals so if you go with the where f is equal to see x dot to fixed of give the number of decimals let us take some three decimals here and let us print here so let's get here so to fix it function right so i will print here we have can observe here two fixed is 15.00 so that means we are restricting to three decimals so automatically three decimals will be added right so initially x value is 15 and now it is a fifteen point zero zero zero because we are restricting to the three decimals if you go with the six decimals automatically it will be printed with the six decimals so if some where n is equal to five point three four five six seven eight five point three four five six seven eight now if you rested this one n dot to fix it with three so you can observe here it's the result is five point three four six five point three four six it will be rounding up okay it will be rounding up up to the three decimals if you go with the four decimals five point three four five seven we'll get this one by seven so you will get three four five seven right so like this in order to restrict with the decimal values we'll go with this two fixed function and there is one more function called two precision so total number of length the length of the value can be restricted with the help of this precisions okay p is equal to n dot 2 precision of so if you consider this length that means number of digits 1 2 3 4 5 6 7 digits are there so here you can restrict with the three digits you can restrict with the three digits now you can print the p value here so see precision function and here instead of f we have to give p and if you execute this one you will get the value the length of the number will be three and you can one one important thing the result of all these functions are string so if you go with the exponential form this is not a number this is a string and two friction function this is not a number this is also a string and two precision function this is also a string right see and you you can observe here so see i i will let us check whether the type of this one so type of p okay type of p and you can observe type of p so type of p is a string that means p means nothing but a precision precision function the result of precision function is stored in p so type of p is a string and if it is ef if it is f that means two fixed function so then also we'll get a string and you can observe type of f is a string and similarly exponential so type of e even type of e is also a string you can observe here type of e is also a string right so the result of all these number methods will be of string data type now there are a few functions in order to convert the variables to numbers variables two numbers now see if you convert this number sorry ah let it be some a is equal to where a is equal to sorry where a is equal to number of see number of let us take some yes sorry e will go with the e right let us check let us check okay type of a and a you can you can observe type of a is a number so initially e is a string so just now we have seen e is a string and we are converting that string to a number by using a number function is a type just like a type conversion right so by using this number function the variables will be converted into a numbers okay and also we can go with the percent and pass float parse int and pass flow see where b is equal to go with the parse end of let us take some f let us take some f and also we just with one so type of b type of b and here also go with the type of b so that you can get the value c number okay so that means we can convert any variable to a numbers so we can use a percent or parsi float or number function so if you print this b value if you print this b value see value of b b br right now let us check see value of b is 5 so initially there will be percent of f that means see two fixed function f value is this one 5.3457 but parsing will convert the variable in integer value okay integer value similarly we can have the same thing in a float c and float so automatically we can check the value of c c c and c so we are we are checking the type and the value of this one so type of c is number and value of c is 5.3457 because it's a float it's a float so previously f is a string okay previously the value of f is a string right but by using these functions number percent and pass float we can convert the numbers into i mean variables into numbers okay and then the last thing that is properties so we have also seen the properties for number method so these properties are not valid for variables not belongs to the variables okay so we can't have the properties for variables if it is a number object then we can have the values see we have seen some uh five values so five properties minimum value maximum value positive infinity negative infinity and not a number so let us check so h1 number properties i will write here so document of this one i will print here so here instead of this one we will check min value for bin value in order to print the minimum value minimum value that a variable can accept is so just we have to call with the help of number object number dot mean value so you can observe here sorry right so sorry here we have to write in this format so yes right document dot right ln so you can have c okay so this is a minimum value right minimum value this is the minimum value that an integer can uh the variable can accept okay and similarly a maximum value so what is the maximum value that javascript script can accept there is a max value and the number dot max value so we'll get the maximum value that javascript can accept this is the maximum value right e plus 3 naught eight that is a scientific uh representation that is ten power three naught eight this is ten power minus three twenty four this is the minimum value this is the maximum value and similarly positive infinity infinity positive infinity let us check positive infinity and same number dot same thing positive infinity right so let us check we'll get the positive infinity as infinity and similarly negative infinity so if it is negative infinity minus infinity we should get the minus infinity right so negative infinity and here also we should get negative infinity you can observe negative infinity is minus infinity minus infinity and there is one more property called not a number so if any arithmetic operations if any computations is having some non-numeric string then automatically will get the not a number not a number right so number dot n a n okay n n a n so we'll get this not a number that means a non-numeric string if you are performing any operations with a non-numeric string we will get this not a number not a number right so these are the things we just covered in this session that is about numerous number objects and then the number methods and how to convert the variables to a numbers and number properties okay so all these things for number object right hope you understood this thing so if you are having any doubts regarding these number objects feel free to post your doubts in the comment section so that definitely will try to clarify all your thoughts and if you really understood my session like my session share my session with your friends and don't forget to subscribe to our channel thanks for watching thank you very much
Info
Channel: Sundeep Saradhi Kanthety
Views: 2,616
Rating: undefined out of 5
Keywords: sundeep, saradhi, kanthety, html, introduction, basics, markup language, static, webpages, web browser, text editor, txt file, extention, .html, .htm, java scripting, front end, tags, html elements, html fundamentals, web serevices, java script, applications of java script, script tag, javascript file, scripting language, validation, numbers, number objects, number methods, conversions, number properties, tostring, toexponential, tofixed, toprecision, number objects in java script
Id: 3UuR_xlRJbU
Channel Id: undefined
Length: 36min 2sec (2162 seconds)
Published: Tue Jan 12 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.