Extraction In Javascript: How Would You Write Your Own Code? - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Extraction In Javascript: How Would You Write Your Own Code? (649 Views)
| Extraction In Javascript: How Would You Write Your Own Code? by thanksjosh005(op): 12:06pm On Jun 10, 2022 |
Hello house.... What are your takes on this? Probably, which of these algos would you use when writing codes or do you have your own method as well? Method 1 implies a more technical use of the JavaScript slice() method while Method 2 looks much like a simpler method for extracting a specified amount of string. Method 1 truncate_string = function (str1, length) {Method 2 let text = "Hello world!"; Reference: JavaScript: Extract A Specific Number of Characters from a String url: https://www.w3resource.com/javascript-exercises/javascript-string-exercise-4.php JavaScript String slice() url:https://www.w3schools.com/jsref/jsref_slice_string.asp |
| Re: Extraction In Javascript: How Would You Write Your Own Code? by thanksjosh005(op): 12:56pm On Jun 10, 2022 |
Method 1 is very succinct and clearly self-explained. Writing such algo could be based off your techne or mastery with writing codes. Method 1 can be broken down into concepts in JavaScript like • JS object three ways objects can be written: via ° string literal ° the new keyword ° object constructor Here the object constructor type was used which always include executing the code with the JS function keyword • JS operators comparison and tenary operators were used • JS if/else • JS slice() method A practical understanding of these can help you understand the technicality of Method 1 JS is extensive and consists of various ways you can write code & build algos. Because we likewise have several existing versions of JS, familiarity with JS versions could also help you write various methods for your algos too. ![]() |
| Re: Extraction In Javascript: How Would You Write Your Own Code? by Deicide: 2:44pm On Jun 10, 2022 |
|
| Re: Extraction In Javascript: How Would You Write Your Own Code? by Nobody: 2:57pm On Jun 10, 2022 |
Shortest and fastest way posible |
| Re: Extraction In Javascript: How Would You Write Your Own Code? by thanksjosh005(op): 3:33pm On Jun 10, 2022 |
Deicide:Of course! Thanks for the addition. |
| Re: Extraction In Javascript: How Would You Write Your Own Code? by thanksjosh005(op): 3:35pm On Jun 10, 2022 |
GREATIGBOMAN:Lol... I agree |
Javascript:how Do I Use drawBox Function.. • Can You Write Codes With A Tablet Instead Of A Laptop? • How Do I Convert Object To Arrey In Javascript • 2 • 3 • 4
QR Code Monkey - Free Qr Code Generator • A Nairalander Creates A Music App Using React And Django REST • Why Is This Try Catch Not Working
