Difference between window.location.href, window.location.replace, and window.location.assign in JavaScript

Arjun Thakur
Updated on 23-Jun-2020 12:14:47

685 Views

The window object includes the location object in JavaScript. It includes the following properties −window.location.hrefIt returns the URL of the current page.Example           Click below to get the complete URL of the page.       URL                function display() {             var res = location.href;             document.write(res);          }           window.location.replaceIt is used to replace the current document.Example           Replace current document                function display() {             location.replace("https://www.qries.com")          }           window.location.assignIf you want to load a new document, use JavaScript assign.Example           Open new document                function display() {             location.assign("https://www.qries.com")          }          

Find Maximum Between 2 Numbers Using C#

George John
Updated on 23-Jun-2020 12:12:53

2K+ Views

Firstly, declare and initialize two numbers.int num1 = 50; int num2 = 90;With that, use if-else to find the maximum number.if (num1 > num2) {    maxNum = num1; } else {    maxNum = num2; }Above, we have set the maximum value to the variable maxNum and printed it later on.The following is the complete example to find maximum between 2 numbers in C#.Example Live Demousing System; namespace Demo {    class Program {       static void Main(string[] args) {          int num1 = 50;          int num2 = 90;     ... Read More

Create a Thread in C#

Chandu yadav
Updated on 23-Jun-2020 12:11:59

716 Views

Threads are lightweight processes. A thread is defined as the execution path of a program. Threads are created by extending the Thread class. The extended Thread class then calls the Start() method to begin the child thread execution.Example of Thread: One common example of use of thread is implementation of concurrent programming by modern operating systems. Use of threads saves wastage of CPU cycle and increase efficiency of an application.The following is an example showing how to create a thread.Example Live Demousing System; using System.Threading; namespace Demo {    class Program {       public static void ThreadFunc() {   ... Read More

Create Tuple with String and Int Items in C#

karthikeya Boyini
Updated on 23-Jun-2020 12:11:10

450 Views

Firstly, set two items in the tuple.Tuple tuple = new Tuple(20, "Tom");Now check for first item in the tuple, which is an integer.if (tuple.Item1 == 20) {    Console.WriteLine(tuple.Item1); }Now check for second item in the tuple, which is a string −if (tuple.Item2 == "Tom") {    Console.WriteLine(tuple.Item2); }The following is an example to create a tuple with string and int items.Example Live Demousing System; using System.Threading; namespace Demo {    class Program {       static void Main(string[] args) {          Tuple tuple = new Tuple(20, "Tom");          if (tuple.Item1 == 20) { ... Read More

Create an Infinite Loop in C#

Arjun Thakur
Updated on 23-Jun-2020 12:10:34

1K+ Views

An infinite loop is a loop that never terminates and repeats indefinitely.Let us see an example to create an infinite loop in C#.Exampleusing System; namespace Demo {    class Program {       static void Main(string[] args) {          for (int a = 0; a < 50; a--) {             Console.WriteLine("value : {0}", a);          }          Console.ReadLine();       }    } }Above, the loop executes until a < 50. The value of is set to 0 initially.int a = 0;The value of a decrements after each iteration since it is set to.a--;Therefore the value of a will never be above 50 and the condition a

Create Arrays Dynamically in C#

Samual Sam
Updated on 23-Jun-2020 12:10:04

5K+ Views

Dynamic arrays are growable arrays and have an advantage over static arrays. This is because the size of an array is fixed.To create arrays dynamically in C#, use the ArrayList collection. It represents ordered collection of an object that can be indexed individually. It also allows dynamic memory allocation, adding, searching and sorting items in the list.The following is an example showing how to create arrays in dynamically in C#.Example Live Demousing System; using System.Collections; namespace CollectionApplication {    class Program {       static void Main(string[] args) {          ArrayList al = new ArrayList();     ... Read More

Set Column Rule Properties with JavaScript

Samual Sam
Updated on 23-Jun-2020 12:10:04

224 Views

The columnRule property is used in JavaScript to set the column rule. It allows you to set the style, color, and width between column rule.ExampleYou can try to run the following code to set the column rule properties with JavaScript −Live Demo           Click below to create 4 columns       Columns                This is demo text. This is demo text. This is demo text. This is demo text.          This is demo text. This is demo text. This is demo text. This is ... Read More

Set Font Properties in One Declaration with JavaScript

Sharon Christine
Updated on 23-Jun-2020 12:08:47

136 Views

To set all the font properties, use the JavaScript font property. You can try to run the following code to set all font properties in a single declaration with JavaScript −ExampleLive Demo           Heading 1                This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text.          This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text.             Set Font                function display() {             document.getElementById("myID").style.font = "italic 15px verdana,sans-serif";          }          

Create Custom Attributes in C#

karthikeya Boyini
Updated on 23-Jun-2020 12:08:35

324 Views

Custom attributes that can be used to store declarative information and can be retrieved at run-time.Let us see how to declare custom attribute.[AttributeUsage ( AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true)] public class DeBugInfo : System.AttributeFor our example, let us construct a custom attribute named DeBugInfo, which stores the information obtained by debugging any program.The DeBugInfo class has three private properties for storing the first three information and a public property for storing the message. Hence the bug number, developer's name, and date of review are the positional parameters of the DeBugInfo class and the ... Read More

Create JavaScript Regexes Using String Variables

Abhinaya
Updated on 23-Jun-2020 12:07:53

172 Views

Yes, use new RegExp(pattern, flags) to achieve this in JavaScript.You can try to run the following code to implement JavaScript regex using string variables −                    var str = 'HelloWorld'.replace( new RegExp('hello', 'i'), '' );          document.write(str);          

Advertisements