Can anyone explain to me in JavaScript language what "pointers" are? -
I am a JavaScript coder who is learning Go: I am following this tutorial:
Package main import ("fmt" "math") type Vertex struct {X, Y float64} func (v * Vertex) Abs () float64 {return mathemat .Sqrt (vX * vX + vY * vY)} func main () {V: = & amp; Vertex {3, 4} fmt.Println (v.Abs ())}
What I have given in Wikipedia and GoDocs, but I still can understand them. Can anyone explain me in javascript language?
These are similar to object references in js and others, but not much powerful than indicative references (And thus, more dangerous) consider the following JS code.
var a = {foo: true}; Var B = A; A.foo = false; Console.log (b); // Output: "object {foo: false}"
Both a
and b
are like expressions here when you B = a
, you do not clone an object, you create
type T struct {Foo bool} a: = T {Foo: true} b: = a a.Foo = false Fmt.println (b) // b is a copy, so it has not been changed. Print "{true}" Pa: = & amp; Amp; T {Foo: true} pb: = pa pa.Foo = false fmt.Println (pb) // pb indicates the same structure as the digit, so it prints "& amp; false" {/ The key difference is that in js you can not actually convert the object inside the function. var a = {foo: true}; (Function (x) {x = {fu: false}}) (a); Console.log (a); // Output: Go to "object {foo: true}"
You can do it properly:
pa: = & amp; T {Foo: True} F Mark (P * T) {* p = T {Foo: false}} (PE) fmt.Println (pa) // Output: & amp;; {False}
Another difference is that you can not make pointers to just strokes, but any type of pointer, including.
Comments
Post a Comment