JSON Parse Function in JavaScript

Samual Sam
Updated on 25-Jun-2020 12:03:33

214 Views

The JSON.parse() function accepts a JSON string, and constructs an object based on the given text and, returns it.SyntaxIts Syntax is as followsJson.parse();Example Live Demo    JavaScript Example           var jsonSample = '{"Tutorial": "Java", "Version":8 }';       jsonObj = JSON.parse(jsonSample);       document.write("Tutorial Name: " + jsonObj.Tutorial);       document.write("");       document.write("Tutorial Version: " + jsonObj.Version);     OutputTutorial Name: Java Tutorial Version: 8

JSON.stringify Function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 12:03:07

289 Views

The stringify() function of a JSON object accepts a JSON string, and constructs an object based on the given text and, returns it.SyntaxIts Syntax is as followsJson.stringify();Example Live Demo    JavaScript Example           var jsonSample = '{Tutorial: Java, Version:8}';       jsonObj = JSON.stringify(jsonSample);       document.write(jsonObj);     Output"{Tutorial: Java, Version:8}"

Check If a Large Number is Divisible by 11 in Java

Chandu yadav
Updated on 25-Jun-2020 12:03:01

2K+ Views

A number is divisible by 11 if the difference between the sum of its alternative digits is divisible by 11.i.e. if (sum of odd digits) – ( sum of even digits) is 0 or divisible by 11 then the given number is divisible by 11.Programimport java.util.Scanner; public class DivisibleBy11 {    public static void main(String args[]) {       Scanner sc = new Scanner(System.in);       System.out.println("Enter a number :");       String num = sc.nextLine();       int digitSumEve = 0;       int digitSumOdd = 0;            for(int i = 0; i

Display the Current Method Name in Java

Smita Kapse
Updated on 25-Jun-2020 12:02:51

2K+ Views

The current method name that contains the execution point that is represented by the current stack trace element is provided by the java.lang.StackTraceElement.getMethodName() method.A program that demonstrates this is given as follows −Example Live Demopublic class Demo {    public static void main(String args[]) {       System.out.println       ("The method name is: " + new Exception().getStackTrace()[0].getMethodName());    } }OutputThe method name is: mainNow let us understand the above program.The method getMethodName() is used to obtain the current method name that contains the execution point that is represented by the current stack trace element. This is printed using ... Read More

Map and Set Function in JavaScript

Samual Sam
Updated on 25-Jun-2020 12:02:43

106 Views

The set() function of Map object adds or updates elements (key-value pairs) to a Map object.SyntaxIts Syntax is as followsmapVar.set()Example Live Demo    JavaScript Example           var mapVar = new Map();       mapVar.set('1', 'Java');       mapVar.set('2', 'JavaFX');       mapVar.set('3', 'HBase');       mapVar.set('4', 'Neo4j');       document.write(mapVar.has('3'));     Outputtrue

Check Divisibility of Large Number by 9 in Java

Arjun Thakur
Updated on 25-Jun-2020 12:01:29

1K+ Views

If the sum of the digits of a number is divisible by 9, then the number is divisible by 9.Some examples of numbers divisible by 9 are as follows. The number 51984 is divisible by 9 because the sum of its digits (5+ 1 + 9 + 8 + 4 = 27) is divisible by 9.The number 91403 is not divisible by 9 because the sum of its digits (9 + 1 + 4 + 0 + 3 = 17) is not divisible by 9.Programimport java.util.Scanner; public class DivisibleBy9 {    public static void main(String args[]) {       Scanner sc = new Scanner(System.in);       System.out.println("Enter a number :");       String num = sc.nextLine();       int digitSum = 0;       for(int i = 0; i

Amazing Facts Related to Facebook

Madhuparna
Updated on 25-Jun-2020 12:00:53

180 Views

As of the first quarter of 2018, Facebook had 2.19 billion monthly active users. In the third quarter of 2012, the number of active Facebook users had surpassed one billion, making it the first social network ever to do so. Active users are those, which have logged in to Facebook during the last 30 days.The number of mobile Facebook users across the globe in 2018 is 1.34 Billion.Facebook's total quarterly revenue as of the first quarter of 2018 has amounted to 11.96 billion U.S. dollars, the majority of which were generated through advertising.24 Aug 2015, a billion people used Facebook ... Read More

GCD of an Array of Numbers in Java

Ankith Reddy
Updated on 25-Jun-2020 12:00:32

2K+ Views

ProgramFollowing is the example to calculate the GCD of the numbers of an array.Live Demopublic class GCDOfArrayofNumbers{    public static int gcd(int a,int b){       int res = 0;       while (b > 0){          int temp = b;          b = a % b;          a = temp;          res = a;       }       return res;    }    public static void main(String arg[]){       int[] myArray = {3, 6, 8};       int result = gcd(myArray[0],myArray[1]);       for(int i = 2; i < myArray.length; i++){          result = gcd(result, myArray[i]);       }       System.out.println("Gcd of n numbers is: "+result);    } }OutputGCD of n numbers is: 1

How Off-the-Record Chat Option of Gmail Works

Madhuparna
Updated on 25-Jun-2020 11:59:59

95 Views

One of the features in Google hangouts ensures that no record of your chat history is stored. To enable this, you simply have to go to −Hangouts> Open any conversation> Go to Setting> check for the option 'Conversation History'> Uncheck the box placed in front of this option>Checked: History is turned on.Unchecked: History is turned off.Now the answer to your another question on retrieving the messages is that 'You, as a user' cannot retrieve; however, your employer, in case you use a shared network, can not only see but retrieve even from 'off' mode. Although, I know that Gmail claims ... Read More

LCM of an Array of Numbers in Java

George John
Updated on 25-Jun-2020 11:59:39

4K+ Views

L.C.M. or Least Common Multiple of two values, is the smallest positive value which the multiple of both values.For example multiples of 3 and 4 are:3 → 3, 6, 9, 12, 15 ...4 → 4, 8, 12, 16, 20 ...The smallest multiple of both is 12, hence the LCM of 3 and 4 is 12.ProgramFollowing example computes the LCM of array of numbers.Live Demopublic class LCMofArrayOfNumbers {    public static void main(String args[]) {       int[] myArray = {25, 50, 125, 625};       int min, max, x, lcm = 0;             for(int i = 0; i

Advertisements