Javascript: How to Sort a regular object based on key and value
Assume like you have an object { '1': 1, '3': 1, '4': 3, '5': 1 } and you would like to sort it by its value.
Then you can follow below way. I just added debug information to help with visulization but the function you need is simply
Sort by value
Object.entries(obj).sort(function(a, b) { return a[1] - b[1] });
And...
Notes: GoLang - Types & Methods - Part I
Notes: GoLang - Types & Methods - Part I
Go is a statically typed language with both built in types and user defined types.
Abstraction methods allowed in go, which allowing you to write code that invokes methods without inplementation.
Types in Go
Like we define structs, we can also define any other type in go, for example all below declarations are valid in go
type Student...
Notes: GoLang - Maps vs Slices and Using Slice as buffer
Notes: GoLang - Maps vs Slices and Using Slice as buffer
Maps vs Slices
In go maps are refernce oriented. If you pass a map to a function as argument, any changes to that map inside the function will reflect to original function as well.
package main
import (
"fmt"
)
func main() {
var testMap = make(map[string]string)
testMap["lang"] = "go"
fmt.Println("Before updating...
Notes: GoLang
February 08, 2022
Raaz
anonymous functions, blockers, case, channels, Go Concurrency, Go Routines, select, sync, timer, workers
No comments
Edit
Notes: GoLang
GoLang Notes
Outline
Iterate Over String
Switch Case
Execute Shell Commands
Iterate_Over_String
var name string;
name = "GoLang";
for index, value := range name {
fmt.Printf("Index %d Char %c\n", index, value);
}
Switch-Case
for _, value := range "Golang" {
switch value {
case 'G' : fmt.Println("Case G executed")
case 'l' : fmt.Println("Case I executed")
...
Few Tips To Overcome Unstable Mind
Few Tips To Overcome Unstable Mind
The silly truth I realized, when you have fears, and if your mind becomes unstable, then events happening in your day might take over you and your day and that will lead to procrastination, the feeling of dont want to do anything.
In some other words, we might also call it as depression and if you also feel that the task at your hand is either...
Subscribe to:
Posts (Atom)