forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJs.Obj.html
128 lines (106 loc) · 5.83 KB
/
Js.Obj.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../api_static/tomorrow-night.css">
<link rel="stylesheet" href="../api_static/style.css" type="text/css">
<script src="../api_static//highlight.pack.js"></script>
<script src="../api_static//script.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<meta charset="utf8">
<link rel="previous" href="Js.Math.html"><link rel="next" href="Js.Typed_array.html">
<title> Js.Obj </title></head>
<body>
<nav class="module-index"><ul><li><a href="Bs.html">Bs</a></li>
<li><a href="Bs_dyn.html">Bs_dyn</a></li>
<li><a href="Bs_dyn_lib.html">Bs_dyn_lib</a></li>
<li><a href="Dom.html">Dom</a></li>
<li><a href="Dom_storage.html">Dom_storage</a></li>
<li><a href="Js.html">Js</a></li>
<li><a href="Js_array.html">Js_array</a></li>
<li><a href="Js_boolean.html">Js_boolean</a></li>
<li><a href="Js_cast.html">Js_cast</a></li>
<li><a href="Js_date.html">Js_date</a></li>
<li><a href="Js_dict.html">Js_dict</a></li>
<li><a href="Js_exn.html">Js_exn</a></li>
<li><a href="Js_float.html">Js_float</a></li>
<li><a href="Js_global.html">Js_global</a></li>
<li><a href="Js_int.html">Js_int</a></li>
<li><a href="Js_int64.html">Js_int64</a></li>
<li><a href="Js_internal.html">Js_internal</a></li>
<li><a href="Js_json.html">Js_json</a></li>
<li><a href="Js_list.html">Js_list</a></li>
<li><a href="Js_math.html">Js_math</a></li>
<li><a href="Js_nativeint.html">Js_nativeint</a></li>
<li><a href="Js_null.html">Js_null</a></li>
<li><a href="Js_null_undefined.html">Js_null_undefined</a></li>
<li><a href="Js_obj.html">Js_obj</a></li>
<li><a href="Js_option.html">Js_option</a></li>
<li><a href="Js_primitive.html">Js_primitive</a></li>
<li><a href="Js_promise.html">Js_promise</a></li>
<li><a href="Js_re.html">Js_re</a></li>
<li><a href="Js_result.html">Js_result</a></li>
<li><a href="Js_string.html">Js_string</a></li>
<li><a href="Js_typed_array.html">Js_typed_array</a></li>
<li><a href="Js_types.html">Js_types</a></li>
<li><a href="Js_undefined.html">Js_undefined</a></li>
<li><a href="Js_unsafe.html">Js_unsafe</a></li>
<li><a href="Js_vector.html">Js_vector</a></li>
<li><a href="Node.html">Node</a></li>
<li><a href="Node_buffer.html">Node_buffer</a></li>
<li><a href="Node_child_process.html">Node_child_process</a></li>
<li><a href="Node_fs.html">Node_fs</a></li>
<li><a href="Node_module.html">Node_module</a></li>
<li><a href="Node_path.html">Node_path</a></li>
<li><a href="Node_process.html">Node_process</a></li></ul></nav>
<div class="navbar"><a class="pre" href="Js.Math.html" title="Js.Math">Previous</a>
<a class="up" href="Js.html" title="Js">Up</a>
<a class="post" href="Js.Typed_array.html" title="Js.Typed_array">Next</a>
</div>
<h1>Module <a href="type_Js.Obj.html">Js.Obj</a></h1>
<pre><span class="keyword">module</span> Obj: <code class="type"><a href="Js_obj.html">Js_obj</a></code></pre><div class="info module top">
<div class="not-examples">
Provide utilities for <a href="Js.html#TYPEt"><code class="code">Js.t</code></a><br>
</div>
</div>
<hr width="100%">
<pre><span id="VALempty"><span class="keyword">val</span> empty</span> : <code class="type">unit -> < .. > <a href="Js.html#TYPEt">Js.t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">empty ()</code> returns the empty object <code class="code">{}</code><br>
</div>
</div>
<pre><span id="VALassign"><span class="keyword">val</span> assign</span> : <code class="type">< .. > <a href="Js.html#TYPEt">Js.t</a> -> < .. > <a href="Js.html#TYPEt">Js.t</a> -> < .. > <a href="Js.html#TYPEt">Js.t</a></code></pre><div class="info ">
<div class="not-examples">
<code class="code">assign target source</code> copies properties from <code class="code">source</code> to <code class="code">target</code>
<p>
Properties in <code class="code">target</code> will be overwritten by properties in <code class="code">source</code> if they
have the same key.
<p>
<b>Returns</b> <code class="code">target</code><br>
<div class="tag"> <b>See also</b> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign">MDN</a><br>
</div>
</div>
<div class="examples">
<pre class="example"> <pre class="codepre"><code class="code">(* Copy an object *)
let obj = [%obj { a = 1 }]
let copy = Js.Obj.assign (Js.Obj.empty ()) obj
(* prints "{ a: 1 }" *)
let _ = Js.log copy
</code></pre> </pre><pre class="example"> <pre class="codepre"><code class="code">(* Merge objects with same properties *)
let target = [%obj { a = 1; b = 1; }]
let source = [%obj { b = 2; }]
let obj = Js.Obj.assign target source
(* prints "{ a: 1, b: 2 }" *)
let _ = Js.log obj
(* prints "{ a: 1, b: 2 }", target is modified *)
let _ = Js.log target
</code></pre> </pre>
</div>
</div>
<pre><span id="VALkeys"><span class="keyword">val</span> keys</span> : <code class="type">'a <a href="Js.html#TYPEt">Js.t</a> -> string array</code></pre><div class="info ">
<div class="not-examples">
<code class="code">keys obj</code> returns an array of the keys of <code class="code">obj</code>'s own enumerable properties<br>
<div class="tag"> <b>See also</b> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys">MDN</a><br>
</div>
</div>
</div>
</body></html>