MATH OBJECT (PROPERTIES & METHODS) IN JAVA SCRIPT

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello friends welcome back to our session so in the previous session we have completed the date object so in that we have seen how to create the date and how to so what are the get methods and set methods of data object now in this session we will go with another object that is a math object math object so here if here also we will be having the methods and the properties but one thing we need not create the object with the use of a new keyword before using those methods so we can directly call those methods and also we are having some properties for this math object so those properties can also be used with the help of math name right so first we will see the properties of math and then we'll go with the methods so first one is a properties or constants we can call also constants right so the first one is math dot e is nothing but euler's number so it will return the euler's number so i will execute each and everything and i will show you right so i will demonstrate each and every method and the property and it by executing them by using some code right so don't worry about that now we'll see the syntax and then we'll move on to the system and i will execute all those things the next one is math dot pi p and i should be capital letters so it will return the pi value the value of a pi okay and the next one math dot square root sqrt so sqrt are in capital letters 2 that implies it will return the result of root 2 so square root of 2 okay it will return the square root of 2. similarly there is one more property called math dot sqrt 1 so this is a 1 underscore 2 underscore 2 1 underscore 2 it will give square root of 1 divided by 2 square root of 1 by 2 okay and then the next one math dot ln 2 it gives log 2 similarly math dot ln 10 it gives log 10 and also math dot l 2 e sorry sorry log 2 e it will give log 2 bc similarly math dot log 10g it will give log 10 base t so this these are the properties available in math object so we can directly use them okay if you want to use a pi value we need to give this math dot pi if you want to give give the unless number we need to give math dot e if you want to sum some square root we we are supposed to give the math of square root of 2 so we are also having a method called square root so if you directly want to use this square root root of 2 then directly we can go with this this property okay we need not go with the function directly we can use this property right so these are all the properties of math object now i will execute all these things okay so now we'll see the methods and then we'll move on to the system now we will see the methods so what are the methods available so we will see the method and i will execute them in the system so first one is absolute absolute so the syntax is math dot absolute of some x if you give the minus x we will get the x as a result okay if you give the negative value we'll get the positive value and the second one is cbrt so for that also we have to call with the help of math math dot cbrt of x this gives the cube root of x it gives the cube root of x similarly seal function so that also math dot c of x point let us take directly number 3.45 okay so automatically it will round down so let us take x okay we will see the example there so x then it will automatically round c round up of x it will return round up of x exponential so again math dot exponential of ex it will give e power x okay exponential x power power function so here math dot power of x comma y it will return x power y okay it will give x power y minimum function math dot minimum of x y z p q it will give the minimum value minimum value among all these numbers minimum value among all these numbers similarly we are having another function called max which will to execute this one we need to call math dot max of x y z p q it will give the maximum value it will give the maximum value random for this also we have to call with the help of math math dot random okay this will give random number random number between 0 and 1. so in between 0 and 1 we get the random number so keep on executing this one we get a different results okay next one round function so math dot round of x so if if the decimal value the decimal is less than 5 it will be applying round down round down if the decimal if the decimal greater than or equal to 5 then automatically we'll get the result as round up of x so based upon the decimal value we'll get the result either round up or round down okay square root square root function for this also we will go with the math dot square rt of ex automatically we will get square root of x value square root of x value okay after that truncate truncate so for this again we need to call with the help of math math dot truncate of x automatically it will return only the integer part it returns integer part of x integer part of x and then the trigonometric functions sine so for this we will go with the math dot sign of x okay similarly cos so the syntax is math dot cos of x similarly tan so math dot tan of x so apart from this we can also find hyperbolic sine hyperbolic cos and hyperbolic tan so all these things we can apply so these are the a few methods available in math object so i will execute and i will demonstrate each and every function by executing a small code on the system right so hope you understood the syntax for all these things so if you are having any doubts still so after after watching the execution your doubts will be clarified right so let's move on to the system and execute all these methods hello friends so just now we have seen about the math object methods and the math properties so i will demonstrate each and every method of a math object and a properties by executing a small code so let us start writing the code so first we will begin with the html tags so in between the html tags we will write the body and we will write some title and then we will start writing the script so body so inside the body will give the title as a math object right h1 math object or math properties first let us see the math properties and then we'll go with the math methods math object methods so script and inside the script we can write and actually we have created the objects for the previous thing that is if you observe the data object uh we are using the objects with the help of new keyword but here math is a special thing that we need not create the math object first but directly we can use the methods or properties with the help of math name right so let us start here so there are a few properties which we have seen just now so i will demonstrate this so document uh let us take yeah document.writeln so let us give the some other heading so that the display will be good now so first first property so all the properties and methods should be called with the help of math right so right line right alone math dot e e means a euler's number it will print the euler's number okay see i will go with this one plus and go with the br for for the output to be displayed in the next screen so i am saving this one so math.html so we have got this one so by double clicking on this we will get the this is the euler's number euler's number right and we'll go with the another property these are all these are all the properties these are all not a methods if it is a method you have to use the parenthesis this is a property so properties are nothing but a constant this is a pi value the next one is the pi value we know that 3.14 is a pi value so in order to use the pi in javascript we have to call that pi with the math math object math dot pa so here you can observe we have not created any math object with the use of new keywords so this is a special thing so we need not go with the math object and again there is a one more uh constant called square root sqrt 2 square root of 2 the result of square root of 2 will be getting here right so sqrt is in capital letter and similarly uh there is one more thing called one number property called sqrt one hand underscore two that means one by two the square root of one by two okay you can observe so the square root of 1 by 2 is like this square root of 2 square root of 1 by 2 and similarly math dot log 2 log 2 so this is a result for log 2 and similarly there is one more thing called log 10 log 10 so you will get the value for log 10 and all these are the constants we can go with the constants all right so next one is log 2 e log 2 bc so this is the result for log 2 base e and similarly we are we are having a one more thing called log 2 b log 10 base e okay log 10 basis all these are the constants we can use in our scripting right so let us close this one document dot right ln uh and i am closing here so h2 and now again i am writing one more title so h one with property math object methods okay methods methods in math object right close the h1 you can observe again we have given certain title right now we'll start so document dot write ln first one is absolute so let us take the absolute function plus let's take the absolute function and those functions should be called with the help of math name so math absolute of some minus 10 automatically it will give the positive result right so we can observe here abs one or and again h2 h2 say abs abs of 10 that means even though you are giving some negative value will get the positive value even though we are giving negative value will get the positive value that is absolute value its an absolute value yeah now the next method the next method is cb acting cb atom is a cube root cube root so if if you say it's a cube root c b r t if you go with the 27 right we have to get the 3 as a result right 3 as a result so let us take some here the values will take the value so that it will be displayed and you will not get confused yes now this is the cube root and again we can have the third one that is seal function c seal means round up seal means round up so 3.5 round up 3.5 and this is also a seal okay seal function it's a round up that means it will be moving with the four even though if it is three point one even though it is three point one will get the round up automatically four will get okay and then there is one more function the next function is exponential exponential so here you can observe exponential exp okay exp of 3 and here also you can go with the 3 so that will get the result x exponential 3 value this one right and then next function or next method is a floor it is a round down round down 3.9 also give the round down function okay 3.9 means it rounds down okay float you will get a 3 as a result even though it is a 3.9 will get the result as 3 okay it's a round and then log so logarithmic value some log 2 will take we'll take log 2 so math dot log of 2 so it will give the value of log 2 log 2 value here okay and then the next function is a maximum so it will take it will return the maximum value from the given number of values okay you can take one two three four five and the same thing i am writing here you'll get the maximum value from the given elements so the in the maximum value of given elements is file so automatically we'll get the result as five okay and then similarly minimum so if you write minimum we'll get the minimum value so what is the minimum value 1 so we need to get the result as a 1 right so you can get the result as 1 and now the next one is the power power function power so power function 2 comma 3 and here also i will go with the power function 2 comma 3 2 comma 3 so automatically it will give the result as 2 power 3 that is 8 you can observe here 2 power 3 it's 8 okay hope you understood this one power function and similarly the next function is a random function so there is a function called random function which doesn't take any parameter right any any any value has a parameter and it will return the result a random value between 0 and 1 a random value between 0 and 1 we need not give any parameter here see once again if you execute this one the value of this one will be changed so you can observe here see immediately whenever you refresh you keep on refreshing the page will get the random value but it will be in between 0 and 1 and then a round function the next function is a round function so round you go with the 2.3 around 2.3 will get the round function based upon the precision right so if it is less than the decimal value is less than 0.5 it will go with the round down if it is greater than or equal to 0.5 it will be round up so you can observe it is a less than 2.5 so we will get the round down and if the value is greater than 0.5 we will get a round up you can observe here but here here it is a six okay yeah now you can observe so it's a three right so if it is greater than or equal to point five it is it will be round up if it is a less than 0.5 it will be downtown and the next one is a square root function so square root sq or t of 81 similarly sqrt of 81 so we'll get the result as a 9 okay so you can observe here result as a 9 square root of 81 is 9 right next truncate truncate that means it will omit the decimal values it will give only the integer path front point two point one two three four five similarly trunk two point one one two three four five so automatically we will get the only integer value so you can observe here two okay so if you give the value then also we'll get the same thing see it will omit the decimal values and will get only the integer value right similarly apart from all these methods there are a few methods of integrate trigonometric functions like sine cos tan hyperbolic sine hyperbolic cos hyperbolic 10 so all these functions are also available in math object right so these are the few object methods okay a few methods available in math object so hope you understood this one so if you are having any doubts regarding these properties either properties or methods so feel free to post your doubts in the comment section definitely will try to clarify all your doubts 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: 1,978
Rating: undefined out of 5
Keywords: sundeep, saradhi, kanthety, html, introduction, basics, markup language, static, webpages, web browser, extention, .html, .htm, java scripting, dynamic, front pages, user interface, front end, tags, html elements, html fundamentals, web serevices, hyper text, java script, applications of java script, script tag, head tag, body tag, javascript file, scripting language, validation, server side, math object, properties of math object, methods of math object, constants, math functions
Id: XEtIhm2_-8c
Channel Id: undefined
Length: 22min 58sec (1378 seconds)
Published: Mon Jan 25 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.