Prabhas has Published 95 Answers

What is the best way to initialize a JavaScript number?

Prabhas

Prabhas

Updated on 17-Jun-2020 06:38:06

The best way to initialize a number in JavaScript is to initialize variables while declaring them. Through this, you can easily avoid undefined values.ExampleYou can try to run the following code to initialize a number −Live Demo                    var deptNum = 20, id = 005;          document.write("Department number: "+deptNum);          

What is the difference between JavaScript undefined and void(0)?

Prabhas

Prabhas

Updated on 16-Jun-2020 13:09:36

JavaScript undefinedIt means a variable declared, but no value has been assigned a value.For example, var demo; alert(demo); //shows undefined  alert(type of demo); //shows undefinedHere’s another example showing the usage of undefined to check whether a variable exists or not:ExampleLive Demo                 ... Read More

Can you have a method in Java with varying number of arguments?

Prabhas

Prabhas

Updated on 16-Jun-2020 09:34:09

Yes, we can write a method using variable arguments once you use variable arguments as a parameter method while calling you can pass as many numbers of arguments to this method (variable number of arguments) or, you can simply call this method without passing any arguments.ExampleLive Demopublic class Sample{   ... Read More

What are method local inner classes in Java?

Prabhas

Prabhas

Updated on 16-Jun-2020 09:18:52

In Java, we can write a class within a method and this will be a local type. Like local variables, the scope of the inner class is restricted to the method.A method-local inner class can be instantiated only within the method where the inner class is defined. The following program ... Read More

What is a static class in Java?

Prabhas

Prabhas

Updated on 16-Jun-2020 08:54:31

You cannot use the static keyword with a class unless it is an inner class. A static inner class is a nested class which is a static member of the outer class. It can be accessed without instantiating the outer class, using other static members. Just like static members, a ... Read More

What are generator functions in JavaScript?

Prabhas

Prabhas

Updated on 16-Jun-2020 06:27:28

Generator Functions allows execution of code in between when a function is exited and resumed later. So, generators can be used to manage flow control in a code. Cancel asynchronous operations easily since execution can be paused anytime.Here’s the syntax; do not forget to add an asterisk after the “function” ... Read More

Can we delete the “getContext” property of HTML5 Canvas tag through script?

Prabhas

Prabhas

Updated on 02-Jun-2020 08:12:21

There is no description in HTML5 specification, which says deletion of a getContext property by the script is valid.We can write a code in which we delete getContext property of HTMLCanvasElement and then in the separate statement we make it undefined.Delete window.HTMLCanvasElement.prototype.getContext; _assertSame(window.HTMLCanvasElement.prototype.getContext, undefined,    "window.HTMLCanvasElement.prototype.getContext", "undefined");Read More

How to add multi-language content in HTML?

Prabhas

Prabhas

Updated on 29-May-2020 22:35:53

The lang attribute in HTML allows you to set content for languages other than English. You can try to run the following code to implement lang attribute.ExampleHere, we have added content in French and Spanish as well.           English       This is demo text   ... Read More

Include information about the document in HTML

Prabhas

Prabhas

Updated on 27-May-2020 21:00:49

Use the tag to include information about the document. The HTML tag is used for indicating the head section of the HTML document. Tags included inside head tags are not displayed in the browser window.ExampleYou can try to run the following code to include information about the document ... Read More

How to access nested Python dictionary items via a list of keys?

Prabhas

Prabhas

Updated on 05-Mar-2020 07:19:36

The easiest and most readable way to access nested properties in a Python dict is to use for loop and loop over each item while getting the next value, until the end. exampledef getFromDict(dataDict, mapList): for k in mapList: dataDict = dataDict[k] return dataDict a = {    'foo': 45, 'bar': ... Read More

Advertisements